Taking backups using flat files
This is a physical backup method whereby you take a backup by directly copying the files inside data directory
. Since new data is written while you copy the files, the backup will be inconsistent and cannot be used. To avoid that, you have to shut down MySQL, copy the files, and then start MySQL. This method is not used for daily backups but is well suited during maintenance windows for upgrades or downgrades or while doing a host swap.
How to do it...
- Shut down the MySQL server:
shell> sudo service mysqld stop
- Copy the files into theÂ
data directory
(your directory may be different):
shell> sudo rsync -av /data/mysql /backups or do rsync over ssh to remote server shell> rsync -e ssh -az /data/mysql/ backup_user@remote_server:/backups
- Start the MySQL server:
shell> sudo service mysqld start