-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackupMultipleFoldersIncrementally
132 lines (79 loc) · 3.1 KB
/
backupMultipleFoldersIncrementally
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/bin/bash
# Requirements
# sudo apt install sshfs
scriptdir="$(dirname "$0")"
. "$scriptdir/functions"
mydate=`date -I`
Ask "Source?" "This computer" "SSH"
if [ "$result" == "This computer" ]; then
# ---- edit here -------------------------------------------------
backupfolderlist=( "Documents" "Pictures" )
mountSrc=""
backupfolder00="backintime/"
# -----------------------------------------------------------------
fi
if [ "$result" == "SSH" ]; then
# ---- edit here -------------------------------------------------
backupfolderlist=( "Documents" "Pictures" )
srcsshusername="smith"
srcsship="123.456.789.012"
# -----------------------------------------------------------------
backupfolder00="backintime$srcsshusername/"
echo "----------------------------------------------------------------------------------------------"
mountSrc="/tmp/mountSrc$mydate/"
mkdir -p "$mountSrc"
sshfs -C $srcsshusername@$srcsship: "$mountSrc"
tput setaf 3 # Yellow
ls "$mountSrc"
tput sgr0 # Text reset
Ask "Mounted correctly?" "yes" "no"
if [ "$result" == "no" ]; then
exit;
fi
fi
Ask "Backup Destination?" "SSH" "External Harddrive"
if [ "$result" == "SSH" ]; then
# ---- edit here -------------------------------------------------
destsshusername="smith"
destsship="123.456.789.012"
backupfolder0="Backup/$backupfolder00"
# -----------------------------------------------------------------
mountDest="/tmp/mount$mydate"
backupfolderMount="$mountDest/$backupfolder0"
backupfolder="$destsshusername@$destsship:$backupfolder0"
echo "----------------------------------------------------------------------------------------------"
mkdir -p "$mountDest"
sshfs -C $destsshusername@$destsship: "$mountDest"
tput setaf 3 # Yellow
ls "$mountDest"
tput sgr0 # Text reset
Ask "Mounted correctly?" "yes" "no"
if [ "$result" == "no" ]; then
exit;
fi
fi
if [ "$result" == "External Harddrive" ]; then
# ---- edit here -------------------------------------------------
backupfolder="/media/External/$backupfolder00"
# -----------------------------------------------------------------
backupfolderMount="$backupfolder"
fi
thisbackupfolder="$backupfolder$mydate"
#mkdir -p "$thisbackupfolder"
cd ~
lastbackupfoldershort=`ls -1 --sort=version "$backupfolderMount"| tail -1`
echoCOLOR "last backup folder is $lastbackupfoldershort"
Ask "Is this the first backup? I found: $lastbackupfoldershort as the last backup folder. Correct?" "yes" "no"
if [ "$result" == "yes" ]; then
echo "great. Continue"
else
echo "Please create manually an empty date folder in the backup directory. Then start the script again with this empty folder as a reference."
exit;
fi
for folder in "${backupfolderlist[@]}"; do
echoCOLOR "----------------------------------------------------------------------"
echoCOLOR "Starting: $folder"
bash incrementalBackupFromTo -s -f "$mountSrc$folder" -t "$thisbackupfolder/" -l "../$lastbackupfoldershort"
echo "$folder done, `date +%F\ %T`" >> "$backupfolderMount$mydate/log.txt"
echoCOLOR "Done: $folder"
done