mirror of https://github.com/Chizi123/Scripts.git

Joel Grunbaum
2020-03-21 f7f566f78118667a1404d0149ca0911aaded25a2
Added manual sync option
1 files modified
32 ■■■■ changed files
backup.sh 32 ●●●● patch | view | raw | blame | history
backup.sh
@@ -2,8 +2,26 @@
cd /home/joel/OneDrive
if [ $1 == "sync" ]; then
    echo Syncing
    BACKUP_DIR="/backup/work/"
    echo OneDrive Personal
    rclone sync $BACKUP_DIR "OneDrive_Personal":/Uni -P
    echo NextCloud
    rclone sync $BACKUP_DIR "NextCloud":/Uni -P
    echo GoogleDrive
    rclone sync $BACKUP_DIR "GoogleDrive":/Uni -P
    echo Mega
    rclone sync $BACKUP_DIR "Mega":/Uni -P
    echo unimelb
    rclone sync $BACKUP_DIR "unimelb":/ -P
    echo sout
    rclone sync $BACKUP_DIR "sout":/data/Cloud -P
    exit
fi
LAST="$(duplicacy list | tail -n1 | cut -d' '  -f4)"
CURR="$(duplicacy backup | grep "revision [0-9] completed" | sed 's/[^0-9]//g')"
CURR="$(duplicacy backup | tail -n1 | sed 's/[^0-9]//g')"
#LAST=2
#CURR=4
DIFF="$(duplicacy diff -r $CURR -r $LAST | grep '-')"
@@ -12,13 +30,12 @@
#echo "last - $LAST"
#echo "diff - $DIFF"
if [ -z "$DIFF" ]; then
    duplicacy prune -r $CURR -exclusive
else
    echo "No diff to backup"
fi
duplicacy prune -keep 1:7 -keep 7:30 -exclusive
duplicacy prune -keep 1:7 -keep 7:30 -exclusive > /dev/null 2>&1
if [ -z "$DIFF" ]; then
    duplicacy prune -r $CURR -exclusive > /dev/null 2>&1
else
    echo "New backup $CURR"
BACKUP_DIR="/backup/work/"
rclone sync $BACKUP_DIR "OneDrive_Personal":/Uni &
rclone sync $BACKUP_DIR "NextCloud":/Uni &
@@ -27,3 +44,4 @@
rclone sync $BACKUP_DIR "unimelb":/ &
rclone sync $BACKUP_DIR "sout":/data/Cloud &
#rclone sync $BACKUP_DIR "Oracle":/Uni
fi