#!/bin/sh # # mysql database backup # Copyright 1999-2003 DVL Software Limited # # Available from http://www.freebsddiary.org/samples/database_dump2.sh.txt # Similar to http://www.freebsddiary.org/samples/database_dump.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 # database - the name of database to dump # /pathto/ - the path to the backup file # /usr/local/bin/mysqldump -uuserid -ppassword -c --add-drop-table database > /pathto/forum_backup.txt # # compress it # tar cfz $BackupFile /pathto/forum_backup.txt # # copy it offsite, change user and othersite.org accordingly. # scp $BackupFile user@othersite.org:$BackupFile # # remove the files we created # rm $BackupFile forum_backup.txt