-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbackup-meta
executable file
·88 lines (68 loc) · 1.59 KB
/
backup-meta
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
84
85
86
87
88
#!/usr/bin/env bash
#
# Backup my system.
#
# Commands:
# - prepare | pp
backup_dir=${XDG_BACKUP_HOME:?}
[[ -d $backup_dir ]] ||
exit 1
printf -v horiz %80s
.hd() {
printf '%s\n' "${horiz// /-}" "$1" "${horiz// /-}" 1>&2
}
apt() (
.hd apt
command -- sudo rm -rv -- "$backup_dir/pkgs"
command -- mkdir -pv -- "$backup_dir/pkgs"
cd -- "$backup_dir/pkgs" ||
exit 1
COLUMNS=200 command -- dpkg-query -l >./query.txt
exec -- sudo sh -c '
command -- apt-cache policy >./cache.txt
command -- apt-mark showauto >./auto.txt
command -- apt-mark showmanual >./manual.txt
# command -- cp -v /etc/apt/trusted.gpg ./trusted.gpg
exec apt-clone clone .
'
)
bin() (
.hd bin
exec -- find /var/lib/dpkg/info/ \
-daystart \( -name \*.list -a -mtime -7 \) \
-printf '%f\n' |
exec -- sed 's:.list$::' |
command -- sort >"$backup_dir/7_days.txt"
IFS=:
set -f
exec -- whatis -w \* $PATH /usr/bin/X11 2>&1 |
exec -- sort -u >"$backup_dir/whatis.txt"
)
# init() (
# .hd init
# {
# command -- find /etc/init.d/ -perm /111 -type f -printf '%f\n'
# exec -- find /etc/init -type f -printf '%f\n'
# } |
# exec -- sort -u >"$backup_dir/init.txt"
# )
cclean() (
.hd cclean
exec -- cclean
)
etckeeper() (
.hd etckeeper
cd / ||
exit 1
printf -v d %\(%s\)T -1
exec -- sudo etckeeper commit "$d prepare backup"
)
case $1 in
prepare | pp)
apt
bin
cclean
etckeeper
;;
esac
# vim: set ft=zsh :