-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathincrementalBackupFromTo
More file actions
118 lines (79 loc) · 2.67 KB
/
incrementalBackupFromTo
File metadata and controls
118 lines (79 loc) · 2.67 KB
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
#!/bin/bash
scriptdir="$(dirname "$0")"
. "$scriptdir/functions"
echo "###########################"
echo " Use bash"
echo "###########################"
frompath=""
topath=""
linkdest=""
sizeonly=false
while getopts "sf:t:hl:" optname
do
case "$optname" in
"s")
echo "Option $optname is $OPTARG"
sizeonly=true
;;
"f")
echo "Option $optname is $OPTARG"
frompath=$OPTARG
;;
"t")
echo "Option $optname is $OPTARG"
topath=$OPTARG
;;
"l")
echo "Option $optname is $OPTARG"
linkdest=$OPTARG
;;
"h")
echo ""
echo " Help is always welcome"
echo ""
echo ""
echo " -f Frompath (is needed!!!)"
echo " -t Backup directory"
echo " -l Older Backup path (to make hardlinks to), this path is relative to the Backup directory"
echo " -s Compare sizes of files only (not timestamps)"
echo " Example:"
echo " ~/Skripte/incrementalBackupFromTo -f myfiles/org/ -t backupfiles/secondbackup -l ../firstbackup"
echo " Run it without sh!!!"
exit
;;
esac
done
if [ "$frompath" = "" ]
then
echo "No frompath specified"
exit;
fi
if [ "$topath" = "" ]
then
echo "No topath specified"
exit;
fi
if [ -d "$topath" ]; then
echo "Backup directory exist already! "
echo "Please provide a new directoy name, for the new backup path!"
echo "If not correct please exit in the next 10 seconds?"
sleep 10
fi
mkdir "$topath"
if [ $sizeonly = true ]
then
echo "Size file comparison only"
if [ "$linkdest" = "" ] ; then
echo "No linkpath specified, Creating a full backup"
rsync --size-only --protect-args -avhz --exclude=.thumbnails --exclude=.cache --exclude=.local/share/Trash/ --exclude=.Private --exclude=.ecryptfs "$frompath" "$topath"
else
rsync --size-only --protect-args -avhz --exclude=.thumbnails --exclude=.cache --exclude=.local/share/Trash/ --exclude=.Private --exclude=.ecryptfs --link-dest="$linkdest" "$frompath" "$topath"
fi
else
if [ "$linkdest" = "" ] ; then
echo "No linkpath specified, Creating a full backup"
rsync --protect-args -avhz --exclude=.thumbnails --exclude=.cache --exclude=.local/share/Trash/ --exclude=.Private --exclude=.ecryptfs "$frompath" "$topath"
else
rsync --protect-args -avhz --exclude=.thumbnails --exclude=.cache --exclude=.local/share/Trash/ --exclude=.Private --exclude=.ecryptfs --link-dest="$linkdest" "$frompath" "$topath"
fi
fi