Thursday, September 6, 2007

tar bz2 backup over ssh


# check for root
if [ `id -u` != 0 ]
echo "this script should be run as root:"
echo " sudo screen $0"
read -p "press [enter] to abort..." cd
exit 1

echo "remember to run this inside screen."
read -p "press [enter] to continue..." cd

echo "dumping mysql database..."
mysqldump -u root --all-databases | bzip2 > ~/all_databases.sql.bz2

echo "starting backup. you will need to enter the password for leo@photon."
sudo tar cjf - --exclude=/tmp --exclude=/var/tmp --exclude=/lost+found --exclude=/proc --exclude=/sys --exclude=/mnt --exclude /media --exclude /home/leo/backup-photon / | ssh leo@photon "cat > ~/backup-nslu2/backup-nslu2_`date +%y-%m-%d`.tar.bz2"

No comments: