-
Notifications
You must be signed in to change notification settings - Fork 3
/
save-local.sh
executable file
·49 lines (45 loc) · 1.31 KB
/
save-local.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
48
49
#!/bin/bash
FILES=(
$XDG_CONFIG_HOME/vim
$XDG_CONFIG_HOME/terminator
$XDG_CONFIG_HOME/wgetrc
$XDG_CONFIG_HOME/git
$XDG_CONFIG_HOME/X11
$XDG_CONFIG_HOME/docker
$XDG_CONFIG_HOME/tmux
$XDG_CONFIG_HOME/bash_completion
$XDG_CONFIG_HOME/cheat
$HOME/.xinitrc
$HOME/.xprofile
$HOME/.profile
$HOME/.bashrc
$HOME/.bash_alias
$HOME/.bash_var
$HOME/.bash_vendor
$HOME/.myclirc
)
# Create Backup Folders in DropBox
DATE=$(date +"%Y%m%d")
FOLDER="$HOME/Dropbox/my-linux/backup/dotfiles-$HOSTNAME-$DATE"
if [ ! -d ~/Dropbox/my-linux/backup ]; then
mkdir -p $HOME/Dropbox/my-linux/backup
fi
if [[ ! -d ~/Dropbox/my-linux/backup/$FOLDER ]]; then
mkdir -p "$HOME/Dropbox/my-linux/backup/$FOLDER"
fi
for item in "${FILES[@]}"; do
if [ -d "$item" ]; then
echo -e "$item is dir to dir config/$(basename $item)"
echo "Copy Directory: $item to $FOLDER"
rsync -rv --exclude=.git "$item" "$FOLDER" # Backup First
rsync -rv --exclude=.git "$item" "./config$item" # item will have a /
rm "config/$item"
echo "copied ./config/$item"
echo "removed ./config/$item"
elif [[ -f "$item" ]]; then
echo "$item is file to 'config/$(basename $item)"
echo "Copy File: $item to $FOLDER"
rsync -v --exclude=.git "$item" "$FOLDER"
rsync -v --exclude=.git "$item" "./config/$item"
fi
done