Light script for backup your MySQL databases.
- Download script
- Set permissions
- Configure database parameters
- Configure backup scripts
- Set up cron job
Ubuntu:
apt install tnftp
Download script "mysql_backup" and "mysql_backup.d" folder (for example, in /usr/local/sbin/mysql_backup/) Create local folder for save backup files (for example, /usr/local/sbin/mysql_backup/backup/)
or
git clone [email protected]:subsan/mysql_backup.git
Database, backup filename prefix and system dir settings in mysql_backup file:
# prefix of archive file
PREFIX="mysql"
# backup dir
BACKUPDIR="/usr/local/sbin/mysql_backup/backup"
# mysql access
MYSQLUSER="root"
MYSQLPASS=""
MYSQLHOST="localhost"
# databases
# comment this string for backup all databases
#DATABASES="test"
This script is able to send backups to different services (FTP, mail, Amazon c3). For each service, there is an executive configuration file in the folder mysql_backup.d
For example, if you want to store backups only on FTP, it is enough to keep the file "ftp" in a folder "mysql_bachkup.d" and set in it settings of access to FTP
If you want to save the configuration on different ftp then you need to duplicate the file "ftp" with a different name in the "mysql_backup.d" folder and configure it to another ftp server
Enter crontab -e and insert the following after editing the folders
1 2 * * * /usr/local/bin/mysql_backup/mysql_backup
@todo add information about install and configure amazon s3