Re:CouchSurfing Deletes Itself, Shuts Down - Old, yet relevant
by shafqat on Saturday August 16, 2008 @09:49AM
(#277723)
I'd love to get people's thoughts on this as well. What are the best ways to automatically back up your DB.
[ Parent
| on HN ]
Re:CouchSurfing Deletes Itself, Shuts Down - Old, yet relevant
by chmac on Sunday August 17, 2008 @03:14AM
(#278242)
For a smaller database, dmpayton's suggestion is spot on. Simply cron schedule a mysqldump and then push that offsite. Here's a few example code snippets I use:
/usr/bin/mysqldump -u dbusername -pdbpassword --skip-lock-tables database_name | gzip > /path/to/backup/file/file_$(/bin/date +\%Y-\%m-\%d_\%H-\%M-\%S).sql.gz
I'm using --skip-lock-tables because on a ZenCart site, the lock tables option was adversely affecting site performance.
Then you could add something to automatically email or scp the file to another host.
For bigger, more complex databases, look into MySQL binary logging, DRBD replication, and MySQL slaves. That should give you some keywords to get started.