blob: fbd1a7c5d9e7e2bac94398cb4656d0a6f452989d (
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
|
#!/bin/bash
#this script backs up personal documents to the vps and personal server
echo -e "backing up files $(date) \n" >> ~/.backuplog
excluded=''
src=''
force=0
excluded_list=""
rsync_args=""
ip='hb'
home="/home/thomas/"
user="thomas"
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}/ ${user}@${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}/./${src}/ ${user}@${ip}:${HB_BACKUP_DIR} | tee -a ~/.backuplog
fi
|