From 53ce7126bccf91abb2e7d3fdb4387b02232e6f1e Mon Sep 17 00:00:00 2001 From: yomguy Date: Sun, 20 Jul 2014 14:55:01 +0200 Subject: [PATCH] add backup --- tc_backup.sh | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 tc_backup.sh diff --git a/tc_backup.sh b/tc_backup.sh new file mode 100755 index 0000000..9188f96 --- /dev/null +++ b/tc_backup.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +set -e + +echo "Please enter the MASTER_HOST address:" +read MASTER_HOST + +echo "Please enter the MASTER_PATH:" +read MASTER_PATH + +echo "Please enter the BACKUP_PATH:" +read BACKUP_PATH + +CLONE=$BACKUP_PATH + +if [ ! -d $CLONE ]; then + mkdir $CLONE +fi + +# CLONING +echo "rsyncing root..." +rsync -a --delete --exclude "/var/*" --exclude "/home/*" --one-file-system $MASTER_HOST:$MASTER_PATH/ $CLONE/ + +echo "rsyncing var..." +DEST=$CLONE/var +if [ ! -d $DEST ]; then + mkdir $DEST +fi +rsync -a --one-file-system --delete $MASTER_HOST:$MASTER_PATH/var/ $CLONE/var/ + +echo "rsyncing home..." +DEST=$CLONE/home +if [ ! -d $DEST ]; then + mkdir $DEST +fi +rsync -a --one-file-system --exclude "archives/*" --exclude "trash/*" --exclude "test/*" $MASTER_HOST:$MASTER_PATH/home/ $CLONE/home/ + +echo "$MASTER_HOST has been backup to $BACKUP_PATH ! :)" -- 2.39.5