dirty snippet of an automated mysqldump & tar
DIRP="location of backups"
DATE=$(date +"%m-%d-%y")
MYSQL_SERVER="location of mysql server"
USER="mysql user"
PASSWORD="mysql password
LOOP_VAR="mysql db names without prefix"
for LOOP_VAR_TXT in $LOOP_VAR
do
LOOP_VAR_FILE=${DIRP}/${LOOP_VAR_TXT}.${DATE}.sql
LOOP_VAR_DB="db prefix"_$LOOP_VAR_TXT
/usr/bin/mysqldump --user=$USER --password=$PASSWORD --host=$MYSQL_SERVER $LOOP_VAR_DB > $LOOP_VAR_FILE
/usr/bin/tar -czvf ${LOOP_VAR_FILE}.tgz $LOOP_VAR_FILE
rm $LOOP_VAR_FILE
done
find ${DIRP}mysql -mtime +13 -exec rm -f {} \;
some quick and dirty code i needed for a quick script
Leave a Reply