|
/Admin/backups/misc:
Backing up a MySQL Database[1]
Simply making a copy of the files in /var/lib/mysql/ while the database is running is not guaranteed to work, as MySQL *might* complain about corruption and refuse to start with such "hot" copies. Of course, if you can afford to stop MySQL while you are taking a snapshot of /var/lib/mysql/, then it should work fine.... The simplest way to grab a copy of a running database is with 'mysqldump'. I use the following, run from cron a couple of times a week:
mysqldump --user=**** --password=**** name-of-database | bzip2 > /var/www/name-of-database/db-backup/name-of-database-backup-`date +%Y-%m-%d`.sql.bz2
backuppc, running on another machine, makes daily backups of the whole /var/www/ directory. If the security of the contents of the database is a concern, do not put the dump in /var/www/.
To delete files that are older then 20 days on a Linux system, add this to your cron:
find /var/www/name-of-database/db-backup/name-of-database-backup* -mtime +20 -exec rm {} \;
[1] http://dev.mysql.com/doc/refman/4.1/en/backup.html
posted at: 13:46 | path: /Admin/backups/misc | permanent link to this entry