[mythtv-users] Really nice MySQL backup script

Intense Red intnsred at golgotha.net
Wed Sep 13 15:28:42 UTC 2006

 > I found a really nice MySQL backup script that handles daily, weekly,
 > and monthly rotations.

   FWIW, here's the one that I use.  With Debian, if I want daily (weekly, 
monthly, etc.) backups I just put the backup script into /etc/cron.daily 
(etc.) or a similar subdirectory.

- - - snip - - -

# Dump all databases on the SQL server:


# ***Edit the below variable: ***

HOSTNAME=`cat /etc/hostname`

# ***Edit the below variable: ***
# No trailing slash below!

TIMESTAMP=`date +%y%m%d`

for EachDatabase in $(echo 'SHOW DATABASES;' |
mysql -u$USER -p$PASSWORD -h$HOST|grep -v '^Database$');
      nice -n 10 mysqldump \
         -u$USER -p$PASSWORD -h$HOST \
         -Q -c -C --add-drop-table --add-locks --quick --lock-tables \
         $EachDatabase > $BACKUPDIR/$HOSTNAME-$EachDatabase-$TIMESTAMP.sql
      nice -n 17 bzip2 $BACKUPDIR/$HOSTNAME-$EachDatabase-$TIMESTAMP.sql

- - - snip - - -

"But woe unto you that are rich! for ye have received your consolation." -- 
Jesus Christ, The Holy Bible, Luke 6:24. (Note He said "woe unto" and 
not "give more tax breaks to".)

More information about the mythtv-users mailing list