-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackup.sh
executable file
·61 lines (48 loc) · 1.27 KB
/
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env bash
UNAME=$(uname)
# cd into script dir
BASEDIR=$(dirname "$0")
cd $BASEDIR
# redirect stdout/stderr to a file
#exec &>> log.txt
adddate() {
while IFS= read -r line; do
printf '%s %s\n' "$(date)" "$line";
done
}
gitupdate() {
if [[ $# = 0 ]]; then
echo "no args"
commit_msg="Updated config $(date)"
else
commit_msg=$1
fi
changed=$(git diff --name-only HEAD)
if [[ $changed ]]; then
echo changed files: $changed
echo uploading to github
git add . > /dev/null
git commit -m "$commit_msg" > /dev/null
git push > /dev/null
else
echo nothing changed
fi
}
main() {
echo "Starting backup ..."
# backup config
rsync -q -av ~/.config/sway ~/.config/waybar ~/.config/kitty ~/.config/nvim ~/.config/zathura config
# backup dotfiles
rsync -q -av ~/.tmux.conf.local ~/.zshrc ~/.gitconfig dotfiles/
if [[ $UNAME = "Darwin" ]]; then
echo Backing up Darwin specific config.
# backup pecan
PECAN_DIR="$HOME/Library/Application Support/Übersicht/widgets/pecan"
cp "$PECAN_DIR/style.css" pecan/
cp "$PECAN_DIR/halcyon.css" pecan/
fi
#gitupdate $1
echo "Backup complete."
}
main $@ | adddate
echo