Files moved from scripts.
This commit is contained in:
102
bin/backup.hdd.sh
Executable file
102
bin/backup.hdd.sh
Executable file
@@ -0,0 +1,102 @@
|
||||
#!/bin/bash
|
||||
|
||||
#set -x
|
||||
|
||||
DATE=/bin/date
|
||||
RSYNC=/usr/bin/rsync
|
||||
TIMESTAMP=`$DATE +%Y%m%d-%H:%M%z`
|
||||
|
||||
LOGFILE=/mnt/hdd/backup/log/backup.$TIMESTAMP.log
|
||||
LOG="/usr/bin/tee -a $LOGFILE"
|
||||
|
||||
function term() {
|
||||
echo "Terminating." | $LOG
|
||||
exit 1
|
||||
}
|
||||
trap term INT
|
||||
|
||||
function backup() {
|
||||
ORIG_DIR=$1
|
||||
MIRROR_DIR=$2
|
||||
shift 2
|
||||
echo ""
|
||||
echo "Sync $ORIG_DIR to $MIRROR_DIR"
|
||||
echo "========================================================"
|
||||
# Use --progress if interactive.
|
||||
$RSYNC -aAXv --delete --force "$@" $ORIG_DIR $MIRROR_DIR 2>&1 | $LOG
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "There were errors while backing up $ORIG_DIR"
|
||||
fi
|
||||
echo ""
|
||||
}
|
||||
|
||||
function backuphdd() {
|
||||
HDD_ORIG=/mnt/hdd
|
||||
HDD_MIRROR=/mnt/hdd2
|
||||
ORIG_DIR=$HDD_ORIG/$1
|
||||
MIRROR_DIR=$HDD_MIRROR/$(dirname $1)
|
||||
backup $ORIG_DIR $MIRROR_DIR
|
||||
}
|
||||
|
||||
function backupwd() {
|
||||
ORIG_DIR=$1
|
||||
MIRROR_DIR=192.168.0.6:/DataVolume/$2
|
||||
backup $ORIG_DIR $MIRROR_DIR
|
||||
}
|
||||
|
||||
function backuplusntag() {
|
||||
ORIG_DIR="vahagn@192.168.0.3:$1"
|
||||
MIRROR_DIR=$2
|
||||
backup $ORIG_DIR $MIRROR_DIR -e "ssh -i /home/vahagn/.ssh/id_rsa"
|
||||
}
|
||||
|
||||
function backupyerevak() {
|
||||
ORIG_DIR="vahagn@yerevak.vostan.org:$1"
|
||||
MIRROR_DIR=$2
|
||||
backup $ORIG_DIR $MIRROR_DIR -e "ssh -i /home/vahagn/.ssh/id_rsa -p 24"
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Log Header
|
||||
#
|
||||
echo Starting $LOGFILE | $LOG
|
||||
echo start `$DATE` | $LOG
|
||||
#
|
||||
# Sync folders
|
||||
#
|
||||
backup "/srv/nextcloud" "/mnt/hdd/backup/docker"
|
||||
backup "/var/lib/docker/volumes" "/mnt/hdd/backup/docker"
|
||||
|
||||
backup "/src/gerbera/music" "/mnt/hdd/public"
|
||||
|
||||
#backup "/srv/gitlab" "/mnt/hdd/backup/gitlab"
|
||||
#backup "/srv/git" "/mnt/hdd/backup/git"
|
||||
|
||||
#
|
||||
# Backup Lusntag
|
||||
#
|
||||
backuplusntag "/home/vahagn/msdos" "/mnt/hdd/backup"
|
||||
backuplusntag "/home/vahagn/devel" "/mnt/hdd/backup/lusntag"
|
||||
backuplusntag "/var/www" "/mnt/hdd/backup/lusntag"
|
||||
backuplusntag "/etc/nginx" "/mnt/hdd/backup/lusntag/etc"
|
||||
#
|
||||
# Backup Yerevak
|
||||
#
|
||||
backupyerevak "/home/vahagn/devel" "/mnt/hdd/backup/yerevak"
|
||||
|
||||
#
|
||||
# Backup hdd1 to hdd2
|
||||
#
|
||||
backuphdd "backup"
|
||||
backuphdd "vahagn"
|
||||
for i in $(ls /mnt/hdd/public); do
|
||||
if [ $i != "movies" ]; then
|
||||
backuphdd "public/$i"
|
||||
fi
|
||||
done
|
||||
|
||||
#
|
||||
# Log Footer
|
||||
#
|
||||
echo end `$DATE` | $LOG
|
||||
Reference in New Issue
Block a user