forked from adam8157/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackup
More file actions
executable file
·43 lines (37 loc) · 686 Bytes
/
backup
File metadata and controls
executable file
·43 lines (37 loc) · 686 Bytes
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
#!/bin/bash
name=$(basename "$0")
dir="${HOME}/dropbox/backup"
file=backup-$(date +%y%m%d).tar.7z
while getopts ":d:f" arg
do
case $arg in
d)
dir="$OPTARG";;
f)
flag="overwrite";;
:)
echo "Error: -$OPTARG needs an argument"
exit 1;;
?)
echo "Usage: $name [-d directory] [-f]"
exit 1;;
esac
done
if [ ! -d "$dir" ]
then
echo "Target directory don't exists, use -d to specify."
exit 1
fi
if [ -f "$dir/$file" ]
then
if [ "$flag" = "overwrite" ]
then
rm -f $dir/$file
else
echo "Target file already exists, use -f to overwrite."
exit 1
fi
fi
tar cf - -C ~ scripts -C ~/backup firefox -C ~/documents dotfiles \
| 7z a -p -si $dir/$file
exit 0