-
Notifications
You must be signed in to change notification settings - Fork 1
/
backup
executable file
·42 lines (37 loc) · 901 Bytes
/
backup
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
#!/bin/sh
# this speaks for itself
backup_location="/Volumes/Teo500GB/backup/"
# directories to backup. recursive, implied to be in home (~)
directories=(
Music
Pictures
Books
)
RSYNC_OPTS="-aLPhz --partial --delete --log-file=$backup_location/`date +d+m+y`.log"
# if --quiet is passed on as an argument, rsync doesnt show the process of the
# backup
if [ -d $backup_location ]
then
if [ "$1" == '-q' ]
then
is_quiet=true
ADDITIONAL_OPTS='--quiet'
elif [ "$1" == '' -o "$1" == '-v' ]
then
ADDITIONAL_OPTS='--verbose'
fi
# BACKUP COMMENCE
for directory in ${directories[@]}
do
if $is_quiet
then
rsync $RSYNC_OPTS $ADDITIONAL_OPTS ~/$directory $backup_location
else
echo 'backing up' $directory
rsync $RSYNC_OPTS $ADDITIONAL_OPTS ~/$directory $backup_location
echo
fi
done
else
echo "$backup_location is not present"
fi