How to Backup MySQL Information using automysqlbackup
There is a utility program called “automysqlbackup” that is available in the Ubuntu repositories.
This utility can be scheduled to automatically perform backups at regular intervals.
To install this program, type the following into the terminal:
sudo apt-get install automysqlbackup
Run the command by typing:
sudo automysqlbackup
The main configuration file for automysqlbackup is located at “/etc/default/automysqlbackup”. Open it with administrative privileges:
sudo nano /etc/default/automysqlbackup
You can see that this file, by default, assigns many variables by the MySQL file located at “/etc/mysql/debian.cnf”. This contains maintenance login information
From this file, it reads the user, password, and databases that must be backed up.
The default location for backups is “/var/lib/automysqlbackup”. Search this directory to see the structure of the backups:
ls /var/lib/automysqlbackup
daily monthly weekly
If we look into the daily directory, we can see a subdirectory for each database, inside of which is a gzipped sql dump from when the command was run:
ls -R /var/lib/automysqlbackup/dailey
.: database_name information_schema performance_schema ./database_name: database_name_2013-08-27_23h30m.Tuesday.sql.gz ./information_schema: information_schema_2013-08-27_23h30m.Tuesday.sql.gz ./performance_schema: performance_schema_2013-08-27_23h30m.Tuesday.sql.gz
Ubuntu installs a cron script with this program that will run it every day. It will organize the files to the appropriate directory.