| xawk.com - technical wisdom served up in little slices | xawk.com -- Tags -- MySql |
| ||||||||
xawk.com -- Tags -- MySql -- Use MYSQLDUMP and CRON to backup Databases
Use MYSQLDUMP and CRON to backup Databases
Use MYSQLDUMP and CRON to backup Databases
If you are keeping any web site data in MYSQL databases, are you making regular backups? "The mysqldump client can be used to dump a database or a collection of databases for backup or for transferring the data to another SQL server (not necessarily a MySQL server). The dump contains SQL statements to create the table and/or populate the table."-- from the MySQL Reference Manual. Technique 1 I wrote a short PERL script to backup my database and compress the results into a unique name based on current date. Sample PERL script --
The $dt variable gets resolved to the current date in YYYYMMDD format. You will need to customize the exec statements where:
As for running it regularly, just set up a CRON job to run it daily, weekly, or whatever. I'm no CRON expert but I use pair hosting so CRON's can be set up from a control panel without any real knowledge. Enjoy this gem of wisdom -- it took me far longer than it should of to figure out what goes on the EXEC command. Technique 2 The wizards at Pair networks sent out this gem of wisdom in one of their monthly newsletters. To back up a particular database, enter this command (all on one line):
Here are the replacement values for the above command:
DBXX.PAIR.COM = The hostname of the database server the database resides on
These commands will generate a file in the "backup" directory off of the home directory called DATABASENAME.DATE where DATE is the date the backup was made. Make sure that a "backup" directory exists off of your home directory when creating these cron jobs. Just set this up to run regularly with cron and you now have regular backups.
Tags: MySql Share: Del.icio.us | Digg | Facebook | Google Bookmarks | Reddit | Technorati | Windows Live | Yahoo! My Web
|
|