forked from geyslan/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackup.sh
executable file
·83 lines (76 loc) · 1.9 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
dest="$PROJS"/dotfiles
[[ ! -d "$dest" ]] && { echo "Destination directory \"$dest\" not found"; exit 1; }
yellow=$(tput setaf 10)
blue=$(tput setaf 4)
reset=$(tput sgr0)
count=
processed=
function bck {
local from="$1"
if [[ ! "$from" = /* ]]; then
echo "\"$from\" is not an absolute path"
exit 1
fi
if [[ ! -f "$from" ]] && [[ ! -d "$from" ]]; then
echo ${yellow}"warning: $from"${reset}" not found"
return
fi
if [[ "$from" == "$HOME"* ]]; then
to=$dest/home"${from#$HOME}"
else
to=$dest/"${from#/}"
fi
if test "$to" -nt "$from"; then
echo ${yellow}"warning: $from "${reset}"is older than"${yellow}" $to (destination wasn't replaced)"${reset}
return
elif [[ -f "$to" ]] && cmp "$to" "$from" 1>/dev/null; then
echo ${blue}"info : $from "${reset}"is equal to"${blue}" $to (nothing done)"${reset}
return
fi
mkdir -p "$(dirname $to)"
echo "copying: $from to $to"
cp -pr $from $to
((++processed))
}
function bck_all {
count=0
processed=0
for from in "$@"; do
bck "$from"
((++count))
done
}
bck_all \
~/.bashrc \
~/.bash_profile \
~/.bash_aliases \
~/.bash_bindings \
~/.bash_profile \
~/.bash_env \
~/.gitconfig \
~/.xbindkeysrc \
~/.config/chrome-flags.conf \
~/.config/i3/config \
~/.config/i3/bin/session \
~/.config/i3/bin/hidpi-scale \
~/.config/i3/bin/wallpaper-changer \
~/.config/i3status/config \
~/.config/compton.conf \
~/.config/gtk-3.0/bookmarks \
~/.config/user-dirs.dirs \
~/.config/nano/nanorc \
~/.config/mpv/mpv.conf \
~/.config/systemd/user/wallpaper-changer.timer \
~/.config/systemd/user/wallpaper-changer.service \
~/.emacs.d/{init.el,config.org} \
/etc/locale.conf \
/etc/vconsole.conf \
/etc/default/grub \
/etc/mkinitcpio.conf \
/etc/X11/xorg.conf.d/70-synaptics.conf \
/etc/X11/xorg.conf.d/10-intel.conf \
/etc/X11/xorg.conf.d/20-amdgpu.conf \
/etc/modprobe.d/i915.conf \
/etc/systemd/system/sleep-fix.service
echo "$processed of $count files processed"