#!/bin/sh # # mysql database backup # Copyright 1999-2003 DVL Software Limited # # Available from http://www.freebsddiary.org/samples/database_dump.sh.txt # Similar to http://www.freebsddiary.org/samples/database_dump2.sh.txt # # See also http://www.freebsddiary.org/dump-restore.html # http://www.freebsddiary.org/mysql-password.php # http://www.freebsddiary.org/mysql.php # # # the name of the backup file. file name format is backup.2000.01.12.at.22.59.48.tgz # BackupFile="forum.backup.`date +%Y.%m.%d.at.%H.%M.%S`.tgz" # # dump the database. # make the following replacements: # # userid - the user id to use when connecting to the database # password - the password for the above user # yourdatabase - the name of database to dump # /pathto/ - the path to the backup file # # WARNING: I advise you to modify the mysqldump call according to the instructions # at http://www.freebsddiary.org/mysql-password.html. This will remove the # password from the command line and put it in ~/.my.cnf: # # [client] # password=yourpassword # /usr/local/bin/mysqldump -uuserid -pyourpassword -c --add-drop-table yourdatabase > /pathto/yourdatabase.sql # # compress it # tar cfz $BackupFile /pathto/yourdatabase.sql # # copy it offsite # ftp -n -v ftp.unixathome.org <