If you have blogs or websites, you databases is one the most important thing. Your data will be store on your database, for this case it is MySQL. MySQL is a free database management system (DBMS) and bundled with Linux as LAMP (Linux, Apache, MySQL and PHP). Because it is so important, then you have to regularly backup your data, as disaster recovery steps.
Actually to backup MySQL data is not hard. There are many tools provide for free to backup with on single click. But sometimes you forget to backup and then when disaster come, you don’t have the latest backup. Of course this can be bad. Data lost is a nightmare!
AutoMySQLBackup is one of the great tools to backup multiple databases, compress the backups, back up remote databases, and email the logs. AutoMySQL lets you take daily, weekly and monthly backups of your MySQL databases using mysqldump (MySQL function to backup the databases).
- Install AutoMySQLBackup:
sudo apt-get install AutoMySQLBackup
- Configure AutoMySQLBackup:
- See the configuration below:
[...] # Host name (or IP address) of MySQL server e.g localhost #For remote database, fill the domain or ip address DBHOST=localhost [...] # List of DBNAMES for Daily/Weekly Backup e.g. "DB1 DB2 DB3" # The following is a quick hack that will find the names of the databases by # reading the mysql folder content. Feel free to replace by something else. #DBNAMES="db_ispconfig web1 web2 web3" DBNAMES=`find /var/lib/mysql -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f5 | grep -v ^mysql$ | tr \r\n , ` [...] # Backup directory location e.g /backups # Folders inside this one will be created (daily, weekly, etc.), and the # subfolders will be database names. #BACKUPDIR="/var/lib/automysqlbackup" #BACKUPDIR="/path/to/backup/folder/" [...] # Email Address to send mail to? ([email protected]) MAILADDR="[email protected]" [...]
- Run AutoMySQLBackup:
- Open the backup folder (default: /var/lib/automysqlbackup)
ls -l /var/lib/automysqlbackup
- You will see the backup files.
- Add it to cron to run it automatically.