All pastes #212018 Raw Edit

Untitled

public text v1 · immutable
#212018 ·published 2006-10-20 17:09 UTC
rendered paste body
#!/bin/bash
archive="/var/DBbackup" #<--make sure this exits
db="mythconverg"
hourly="3"
daily="7"
weekly="2"
monthly="12"

cd $archive
if [ "$1" = "hourly" ]; then
 x=`expr $hourly - 1`
fi
if [ "$1" = "daily" ]; then
 x=`expr $daily - 1`
fi
if [ "$1" = "weekly" ]; then
 x=`expr $weekly - 1`
fi
if [ "$1" = "monthly" ]; then
 x=`expr $monthly - 1`
fi

while [ "$x" -gt "1" ]
do
  y=`expr $x - 1`
  if [ -e $1$db.$y.sql.bz2 ]; then
    mv -f $1$db.$y.sql.bz2 $1$db.$x.sql.bz2
  fi
  x=$y
done
if [ -e $1$db.sql.bz2 ]; then
  mv -f  $1$db.sql.bz2  $1$db.1.sql.bz2
fi

mysqldump $db >$1$db.sql
bzip2 -9 $1$db.sql
#Change the following to where you want to copy the dump to
rsync --delete -az -e "ssh -p 2222 -l DBbackup " . 10.1.1.162:~/DBbackup