#!/bin/sh #This is a simple MySQL database backup script #Prepared by Sitevalley.com in 2009 #***************************************** # !!!Please Note!!! #***************************************** # Sitevalley.com takes no resposibility for any data loss or corruption when using # this script... # You should copy your backups offline regularly for best protection. # Good luck with back ups, and hopefully you will never have to restore your backups! #***************************************** #!/bin/sh #This line shows the cron what utility should be used to execute the commands in this file. # Username to access the MySQL server. In the line below substitute the ‘database_user_name’ #with the appropriate username for the database of your wordpress. USERNAME=database_user_name #***************************************** # Username to access the MySQL server. In the line below substitute the ‘database_password’ #with the appropriate password for the database of your wordpress. PASSWORD=database_password #***************************************** # Host name (or IP address) of MySQL server. Here simply leave the ‘localhost’. DBHOST=localhost #***************************************** # Name of the database to make the backup for. In the line below substitute the ‘database_name’ #with the appropriate name of your wordpress database. DBNAME=database_name #***************************************** # Backup directory location. In the line below substitute the ‘backup_directory’ #with the path to the directory where you want your backups stored. #E.g. /usr/home/username/domains/myblog.com/public_html/wp-backups/ BACKUPDIR="backup_directory" #***************************************** #Specify the age of the backups that should be deleted. #This is needed in order not to pile up the space on account with backups. #(m=month; h=hours, m=minutes, s=seconds). #Substitute the ‘backup_age’ with an appropriate value (e.g. 7d). BPAGE=backup_age #***************************************** #Location of mysqldump command. Here you need to substitute the ‘path_to_mysqldump’ #with the path to the location where the mysqldump command is situated. #E.g. /usr/local/mysql-5.0.51a-freebsd7.0-i386/bin/ MYSQLDUMPLOC="path_to_mysqldump" #No changes needed below this line #***************************************** PATH=$PATH:$MYSQLDUMPLOC; DATE=`date +%Y-%m-%d_%Hh%Mm` mysqldump -u$USERNAME -p$PASSWORD $DBNAME | gzip > $BACKUPDIR/mysql_backup_$DATE.gz; chmod 600 $BACKUPDIR/mysql_backup_$DATE.gz; find $BACKUPDIR -type f -name "*.gz" -mtime +$BPAGE -exec rm -f {} \; #Looking for reliable linux hosting at reasonable prices? Visit http://sitevalley.com - where the sites live!