Razasharp
Well-known member
Interesting thread everyone - I have posted an off-shoot thread here http://xenforo.com/community/thread...estore-your-sites-server-from-a-backup.69176/ will be interesting to see if any failures recur.
http://xenforo.com/community/resources/8wayrun-com-xenutiles-backup-pro.2230/some kind of add on that take cares of backups would also be cool.
#!/bin/sh
# List of databases to be backed up separated by space
dblist=“databasename1 databasename2”
# Directory for backups
backupdir=/backup/mysql
# Number of versions to keep
numversions=14
# Full path for MySQL hotcopy command
hotcopycmd=/usr/bin/mysqlhotcopy
# MySQL Username and password
userpassword=" --user=fill_username_here --password=your_password”
# Create directory if needed
mkdir -p ${backupdir}
if [ ! -d ${backupdir} ]
then
echo "Invalid directory: ${backupdir}"
exit 1
fi
# Hotcopy begins here
echo "Hotcopying MySQL Databases..."
RC=0
for database in $dblist
do
echo "Hotcopying $database ..."
$hotcopycmd $userpassword $database ${backupdir}
RC=$?
if [ $RC -gt 0 ]
then
break;
fi
# Rollover the backup directories
i=$numversions
mv ${backupdir}/${database} ${backupdir}/${database}.0 2> /dev/null
rm -fr ${backupdir}/${database}.$i 2> /dev/null
while [ $i -gt 0 ]
do
mv ${backupdir}/${database}.`expr $i - 1` ${backupdir}/${database}.$i 2> /dev/null
i=`expr $i - 1`
done
done
if [ $RC -gt 0 ]
then
echo "MySQL Hotcopy failed!"
exit $RC
else
# Hotcopy is complete. List the backup versions!
ls -l ${backupdir}
echo "MySQL Hotcopy is complete!"
fi
exit 0
We use essential cookies to make this site work, and optional cookies to enhance your experience.