-
Notifications
You must be signed in to change notification settings - Fork 6
/
backup.sh
executable file
·47 lines (43 loc) · 1002 Bytes
/
backup.sh
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
#!/usr/bin/env bash
copy_dirs=(
~/.gnupg
~/.ssh
~/.aws
~/.npmrc
~/.now
~/.zshrc.local
~/.kube
~/Code
~/Documents
~/Pictures
)
DIRECTORY=$1
if [[ "$DIRECTORY" == "" ]]; then
echo "You must put in an argument to where to backup. ~/Desktop is a common one"
exit 1
fi
if [ ! -d "$DIRECTORY" ]; then
echo "$DIRECTORY is not a valid directory"
exit 1
fi
# Add /backup to the end of the directory
DIRECTORY="$DIRECTORY"/backup
# remove any duplicate / from the path for visual reasons
DIRECTORY=${DIRECTORY//\/\//\/}
for copy_dir in "${copy_dirs[@]}"; do
echo "Copying $copy_dir to $DIRECTORY"
rsync -rv \
--exclude=*.DS_Store \
--exclude=*/node_modules \
--exclude=*/bower_components \
--exclude=*/deps \
--exclude=*/_build \
--exclude=*/.elixir_ls \
--exclude=*/coverage \
--exclude=*/.cache \
--exclude=*/.data \
--exclude=*/dump.rdb \
--exclude=*/*.log \
--exclude=*/*.photoslibrary/* \
"$copy_dir" "$DIRECTORY"
done