Advertisement
Advertisement
| 09.26.2008 at 09:53AM PDT, ID: 23766697 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: |
#!/bin/sh
# List of databases to be backed up separated by space
dblist="testdb testdb2 testdb3"
# Directory for backups
backupdir=/home/mysql/backup
# Number of versions to keep
numversions=4
# Full path for MySQL hotcopy command
hotcopycmd=/usr/bin/mysqlhotcopy
# MySQL Username and password
userpassword=" --user=root --password=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
|
| Answered By: | MikeOM_DBA |
| Expert Since: | 07/01/2002 |
| Accepted Solutions: | 948 |
| Computer Expertise: | Guru |