commit | author | age
|
64e605
|
1 |
#!/bin/sh |
JG |
2 |
|
ae2fb4
|
3 |
BACKUP_DIR="/backup/work/" |
JG |
4 |
FILES_DIR="/home/joel/OneDrive/" |
|
5 |
RCLONE_BACKUP=("OneDrive_Personal" "NextCloud" "GoogleDrive" "Mega" "unimelb" "sout" "pCloud") |
|
6 |
RCLONE_FILES=("sout" "Mega" "unimelb") |
|
7 |
|
|
8 |
function sync() { |
|
9 |
if [ $2 != "p" ]; then |
|
10 |
case $1 in |
|
11 |
"sout") |
|
12 |
rclone sync $BACKUP_DIR $1:/data/Cloud/backup $(! [ -z $3 ] && echo "-P") |
|
13 |
;; |
|
14 |
*) |
|
15 |
rclone sync $BACKUP_DIR $1:/Uni/duplicacy $(! [ -z $3 ] && echo "-P") |
|
16 |
;; |
|
17 |
esac |
|
18 |
else |
|
19 |
case $1 in |
|
20 |
"sout") |
|
21 |
rclone sync $FILES_DIR $1:/data/Cloud/files $(! [ -z $3 ] && echo "-P") |
|
22 |
;; |
|
23 |
*) |
|
24 |
rclone sync $FILES_DIR $1:/Uni/files $(! [ -z $3 ] && echo "-P") |
|
25 |
;; |
|
26 |
esac |
|
27 |
fi |
|
28 |
} |
|
29 |
|
|
30 |
function sync_all() { |
|
31 |
if [ -z $1 ]; then |
|
32 |
for i in ${RCLONE_BACKUP[*]}; do |
|
33 |
sync $i & |
|
34 |
done |
|
35 |
for i in ${RCLONE_FILES[*]}; do |
|
36 |
sync $i p & |
|
37 |
done |
|
38 |
else |
|
39 |
for i in ${RCLONE_BACKUP[*]}; do |
|
40 |
echo -e '\033[0;31m'$i backup'\033[0m' |
|
41 |
sync $i n p |
|
42 |
done |
|
43 |
for i in ${RCLONE_FILES[*]}; do |
|
44 |
echo '\033[0;31m'$i files'\033[0m' |
|
45 |
sync $i p p |
|
46 |
done |
|
47 |
fi |
|
48 |
} |
|
49 |
|
64e605
|
50 |
cd /home/joel/OneDrive |
JG |
51 |
|
9af599
|
52 |
if [ "$1" = "sync" ]; then |
ae2fb4
|
53 |
echo -e '\033[0;32m'Syncing'\033[0m' |
JG |
54 |
sync_all p |
f7f566
|
55 |
exit |
JG |
56 |
fi |
|
57 |
|
64e605
|
58 |
LAST="$(duplicacy list | tail -n1 | cut -d' ' -f4)" |
f7f566
|
59 |
CURR="$(duplicacy backup | tail -n1 | sed 's/[^0-9]//g')" |
64e605
|
60 |
#LAST=2 |
JG |
61 |
#CURR=4 |
|
62 |
DIFF="$(duplicacy diff -r $CURR -r $LAST | grep '-')" |
|
63 |
|
|
64 |
#echo "curr - $CURR" |
|
65 |
#echo "last - $LAST" |
|
66 |
#echo "diff - $DIFF" |
|
67 |
|
5417a6
|
68 |
duplicacy prune -keep 7:30 -keep 1:7 -exclusive > /dev/null 2>&1 |
64e605
|
69 |
|
f7f566
|
70 |
if [ -z "$DIFF" ]; then |
JG |
71 |
duplicacy prune -r $CURR -exclusive > /dev/null 2>&1 |
|
72 |
else |
|
73 |
echo "New backup $CURR" |
ae2fb4
|
74 |
sync_all |
f7f566
|
75 |
fi |