Automated SQL Backup Script
A simple bash script, to automatically create SQL dumps on a daily basis, scheduled by systemd. It comes with a built-in mechanism to check and delete old backups.
Installing / Getting started
Clone the repository and execute the installation script.
sudo git clone https://git.slub-dresden.de/dbod/sql-backup.git /opt/sql-backup
sudo bash /opt/sql-backup/install.sh
systemctl enable sql-backup.service
After the repository is cloned, the installation script is executed. The script first triggers the update script and checks for repository updates. After that, it is copying the systemd service files (.service and .timer) to the appropriate path.
Initial Configuration
The backup script needs an SQL User, capable to lock and dump the databases, which should be backuped. In the standard configuration, the script trys to backup every single database on the server "localhost", using the user "root" without a password. This will most probably result in an error. See further on the Step Configuration.
Developing
To participate in the development of the project, you just need to clone the repository.
git clone https://git.slub-dresden.de/dbod/sql-backup.git
cd sql-backup
Features
Configuration
The script needs the following variables to work. Therefor a file named 'config.json' is loaded. If the file does not exist, a standard configuration will be loaded.
Variable type | variable name | default Value |
---|---|---|
SQL Server Hostname | sqlHost | localhost |
SQL Server Port | sqlPort | 3306 |
User used to connect | sqlUser | root |
List of Databases | dbNames | ($(mysql -u $sqlUser -e "SHOW DATABASES;")) |
Backup Root Directory | backupRoot | /var/backups/sql/ |
Days to keep Backups | backupRetainDays | 30 |
Contributing
"If you'd like to contribute, please fork the repository and use a feature branch. Pull requests are warmly welcome."
Links
- Repository: https://git.slub-dresden.de/dbod/sql-backup
- Issue tracker: https://git.slub-dresden.de/dbod/sql-backup/-/issues
- In case of sensitive bugs like security vulnerabilities, please contact hannes.braun@slub-dresden.de directly instead of using issue tracker. We value your effort to improve the security and privacy of this project!
- Related projects:
- Template for the README.md: https://github.com/jehna/readme-best-practices
Licensing
"The code in this project is licensed under MIT license."