Backing up your WordPress MYSQL database.

July 8th, 2008 admin Posted in Applications, Database, How To: No Comments »

Backing up the MYSQL database is a good idea.  The GUI makes it easy, but the command line lets you do it through cron, which does it when you forget!

Here is the basic syntax:

<em>root@blaster:/# mysqldump -u root -pgetyourownpasswd wordpress &gt; /disk1/backups/wordpress`date ‘+%m%d%y’`.sql</em>

I made a file and called it /usr/bin/dumpdata and put the above code into it and then ran it out of cron.
I also added a tar command to get my root doc as well.

<em>root@blaster:/# crontab -l</em>
# m h  dom mon dow   command
30 2 * * * /usr/bin/do_rsync
5  1 * * * /usr/bin/webalizer
10 1 * * */usr/bin/datadump

The contents of /usr/bin/datadump:

<em>day=`date +%m%d%y`
/usr/bin/mysqldump -u root -pyourpassword wordpress &gt; /data/Linux-Backup/wordpress${day}.sql
/bin/tar cvf /data/Linux-Backup/wordpressbackup${day}.tar /etc/apache2 /var/www /var/www1 </em>

Gives you files like this:

wordpress070208.sql

wordpressbackup070208.tar


US $22.99
Auction Ends: Wednesday Nov-25-2009 6:13:10 PST
Buy this Item   | Watch this Item

US $19.98
Auction Ends: Wednesday Nov-25-2009 13:52:00 PST
Buy this Item   | Watch this Item

US $7.99
Auction Ends: Thursday Nov-26-2009 11:47:06 PST
Buy this Item   | Watch this Item

US $41.49
Auction Ends: Tuesday Dec-01-2009 10:10:16 PST
Buy this Item   | Watch this Item

US $40.99
Auction Ends: Tuesday Dec-01-2009 10:10:18 PST
Buy this Item   | Watch this Item

US $41.49
Auction Ends: Tuesday Dec-01-2009 10:10:21 PST
Buy this Item   | Watch this Item

US $1.86
Auction Ends: Thursday Dec-03-2009 15:17:16 PST
Buy this Item   | Watch this Item

US $10.77
Auction Ends: Saturday Dec-05-2009 13:03:34 PST
Buy this Item   | Watch this Item

AddThis Social Bookmark Button