-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackupFromTo
105 lines (70 loc) · 2.2 KB
/
backupFromTo
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
#!/bin/bash
scriptdir="$(dirname "$0")"
. "$scriptdir/functions"
echo "###########################"
echo " Use bash"
echo "###########################"
frompath=""
topath=""
sizeonly=false
while getopts "sf:t:h" 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
;;
"h")
echo ""
echo " Help is always welcome"
echo ""
echo ""
echo " -f Frompath (is needed!!!)"
echo " -t Topath (default is $out)"
echo " -s Compare sizes of files only (not timestamps)"
echo " Example:"
echo " ~/Skripte/backupFromTo -f /frompath/ -t /topath/"
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
Ask "Do you want to overwride the destination $topath" "yes" "no"
if [ "$result" == "no" ]; then
exit;
fi
if [ $sizeonly = true ]
then
echo "Size file comparison only"
Ask "Do a dry run?" "yes" "no"
if [ "$result" == "yes" ]; then
rsync --dry-run --size-only --protect-args -avhz --delete --delete-after --exclude=.thumbnails --exclude=.cache --exclude=.local/share/Trash/ --exclude=.Private --exclude=.ecryptfs "$frompath" "$topath"
else
rsync --size-only --protect-args -avhz --delete --delete-after --exclude=.thumbnails --exclude=.cache --exclude=.local/share/Trash/ --exclude=.Private --exclude=.ecryptfs "$frompath" "$topath"
fi
else
Ask "Do a dry run?" "yes" "no"
if [ "$result" == "yes" ]; then
rsync --protect-args -avhz --delete --delete-after --exclude=.thumbnails --exclude=.cache --exclude=.local/share/Trash/ --exclude=.Private --exclude=.ecryptfs "$frompath" "$topath"
else
rsync --protect-args -avhz --delete --delete-after --exclude=.thumbnails --exclude=.cache --exclude=.local/share/Trash/ --exclude=.Private --exclude=.ecryptfs "$frompath" "$topath"
fi
fi