blob: 0453b5e05f2802c0bbfa9d479ae20a0c5e4b3936 (
plain)
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
|
#!/bin/bash
#backup_personal_new
#this script backs up personal documents to personal server or any specified source
echo -e "backing up files $(date) \n" >> ~/.backuplog
#required args:
# [src] - folder/file to backup
#optional args:
# [dest hostname] - (hb) hostname/ip of server to backup to
# [x - exlude files matching pattern
# [xf] - exlude files matching patterns from file
# []
excluded=''
src=''
force=0
excluded_list=""
rsync_args=""
ip='grothe.ddns.net'
while getopts ":x:p:f:l:d:" opt; do
case $opt in
x)
echo "excluding files/dirs $OPTARG"
excluded="$OPTARG"
rsync_args=$rsync_args"--exclude $OPTARG "
;;
l)
echo "exluding files/dirs from list from file $OPTARG"
excluded_list="\"$OPTARG\""
rsync_args=$rsync_args"--exclude-from $OPTARG "
;;
p)
echo "backing up path $OPTARG"
src="$OPTARG"
;;
f)
echo "forcing backup of entire home dir.\n"
force=1
;;
d)
echo "destination address = $OPTARG"
ip="$OPTARG"
;;
esac
done
echo $rsync_args
if [ -z "$src" ]
then
if [[ $force == 1 ]]
then
echo "-f set, so will backup entire home dir.\n"
rsync -avzpR -e ssh /home/thomas/ thomas@"$ip":backup | tee -a ~/.backuplog
else
echo "no custom path given. will do nothing.\n"
exit 0
fi
else
#rsync -avzp -e ssh --exclude-from "$excluded_list" --exclude $excluded /home/thomas/$src/ thomas@grothe.ddns.net:backup/$src | tee -a ~/.backuplog
rsync -avzpP --relative -e ssh $rsync_args /home/thomas/./$src/ thomas@"$ip":backup/ | tee -a ~/.backuplog
fi
|