diff options
author | Robert Alessi <alessi@robertalessi.net> | 2019-12-15 15:22:34 +0100 |
---|---|---|
committer | Robert Alessi <alessi@robertalessi.net> | 2019-12-15 15:22:34 +0100 |
commit | 867df0cf3d06a789a92c0c7a012393a5e1a89369 (patch) | |
tree | 8eb10f177dc499f632809b07a64fa9f33c169dcc | |
parent | 5a44e23708e4ac5e83bfea87d8c13cc45a19dc9f (diff) | |
download | x200-my-0.4.tar.gz |
optionally use rsnapshot to have incremental backups0.4
-rw-r--r-- | PKGBUILD | 9 | ||||
-rw-r--r-- | x200-my.confd | 38 | ||||
-rw-r--r-- | x200-my.initd | 50 |
3 files changed, 63 insertions, 34 deletions
@@ -1,21 +1,22 @@ | |||
1 | # Maintainer: Robert Alessi <alessi@robertalessi.net> | 1 | # Maintainer: Robert Alessi <alessi@robertalessi.net> |
2 | 2 | ||
3 | pkgname=x200-my | 3 | pkgname=x200-my |
4 | pkgver=0.3.1 | 4 | pkgver=0.4 |
5 | pkgrel=1 | 5 | pkgrel=1 |
6 | pkgdesc="Service to remove whining noise from Thinkpads X200, power off the wifi on shutdown and optionally backup directories." | 6 | pkgdesc="Service to remove whining noise from Thinkpads X200, power off the wifi on shutdown and optionally backup directories." |
7 | arch=(any) | 7 | arch=(any) |
8 | license=(GPL2) | 8 | license=(GPL2) |
9 | url="http://git.robertalessi.net/x200-my" | 9 | url="http://git.robertalessi.net/x200-my" |
10 | depends=('sysvinit' 'networkmanager' 'acpid' 'intel-gpu-tools') | 10 | depends=('sysvinit' 'networkmanager' 'acpid' 'intel-gpu-tools' 'rsync') |
11 | optdepends=('rsnapshot: for incremental backups') | ||
11 | install=x200-my.install | 12 | install=x200-my.install |
12 | source=('x200-my.initd' | 13 | source=('x200-my.initd' |
13 | 'x200-my.confd' | 14 | 'x200-my.confd' |
14 | 'x200-my-lid.sh' | 15 | 'x200-my-lid.sh' |
15 | 'x200-my-sleep.sh' | 16 | 'x200-my-sleep.sh' |
16 | 'x200-my.sh') | 17 | 'x200-my.sh') |
17 | sha512sums=('96579d18e8639da441b2f0104e453f2ffd34a1c14c77ad08709fc090b168d0030f5074d8c54f116739a4f421286c5d2b64181c66fabd2eee91c371d8aa856395' | 18 | sha512sums=('40d74cc2bce559cc2a08ebcd707279e148d802a5cdeb675cfb5c3abfed453378028a9f78b1be31269d908ad6aacaaaf53b48b13f97d019cdb73156ff92f507b5' |
18 | 'd181ca58ffed55d7d35bd78d2ace09e6c459938f7f7c6cb10feff56de23861feef8b859fde9bb895021efb840a1fe0d3aef7861c7881bb9a793cf9491a2fd17d' | 19 | 'bf6513589b39daad03e4365e61f2026a4cb1801af9d061f38f502c4caa5732d03e529d43f2ec87a4ded952b6a299fdec1c18f302162b0dd28c540299be8987cf' |
19 | '0dc141f1a26f2cd570d49a05bcc9496ba4c49fde39afad46f5a0783e83c07ec810ca81454a28c3241bcffc62ac31274e2a8d726bbd3c1e91d8cf5315b783c3f8' | 20 | '0dc141f1a26f2cd570d49a05bcc9496ba4c49fde39afad46f5a0783e83c07ec810ca81454a28c3241bcffc62ac31274e2a8d726bbd3c1e91d8cf5315b783c3f8' |
20 | '610564aa853c5dbc4e370ec2a4d3b5590e53ed235a1960927c0986a31f6c77d135086b1f5752b56fd511ea4a0294082fc7e98ee2fa7b69b37776a59f45c2ec34' | 21 | '610564aa853c5dbc4e370ec2a4d3b5590e53ed235a1960927c0986a31f6c77d135086b1f5752b56fd511ea4a0294082fc7e98ee2fa7b69b37776a59f45c2ec34' |
21 | 'cb765075f02b5cd16bcfc31571cf7c31ddcd74ff3aa832df1acd96bd8feb62855c0cf90c31c3e0028180765a51eafc5c74fb1f0406dd9172bdc0f5ec02b39f8c') | 22 | 'cb765075f02b5cd16bcfc31571cf7c31ddcd74ff3aa832df1acd96bd8feb62855c0cf90c31c3e0028180765a51eafc5c74fb1f0406dd9172bdc0f5ec02b39f8c') |
diff --git a/x200-my.confd b/x200-my.confd index bc0024d..35d26bd 100644 --- a/x200-my.confd +++ b/x200-my.confd | |||
@@ -4,15 +4,32 @@ | |||
4 | 4 | ||
5 | PWMFREQ_RATE="0x8bb7b16dc5b6a" | 5 | PWMFREQ_RATE="0x8bb7b16dc5b6a" |
6 | 6 | ||
7 | # | 7 | ################## |
8 | # Backup options | 8 | # Backup options # |
9 | # | 9 | ################## |
10 | # Activate autobackup on shutdown (true/false) | 10 | |
11 | # Activate autobackup on shutdown (true/false)? | ||
11 | conf_autobackup="false" | 12 | conf_autobackup="false" |
12 | # Path to backup directory: | 13 | # Use rsnaphot (true/false)? 'false' means 'use rsync': |
13 | conf_backup_path="/mnt/disk" | 14 | use_rsnapshot="false" |
15 | |||
16 | ############################ | ||
17 | # rsync/rsnapshot settings # | ||
18 | ############################ | ||
19 | |||
20 | # Path to backup directory (note that rsnapshot additionally needs | ||
21 | # this to be specified as 'snapshot_root' in /etc/rsnapshot.conf): | ||
22 | conf_backup_path="/mnt/disk/snapshots" | ||
23 | |||
24 | # The following option applies both to rsync and rsnapshot. | ||
14 | # Control file. This (empty) file must exist in the backup directory: | 25 | # Control file. This (empty) file must exist in the backup directory: |
15 | conf_control_file="dobackup" | 26 | conf_control_file="dobackup" |
27 | |||
28 | ###################### | ||
29 | # rsync-only setting # | ||
30 | ###################### | ||
31 | |||
32 | # rsync only option: | ||
16 | # Directories to backup: | 33 | # Directories to backup: |
17 | conf_backup_dirs=( | 34 | conf_backup_dirs=( |
18 | "/etc" | 35 | "/etc" |
@@ -20,3 +37,12 @@ conf_backup_dirs=( | |||
20 | "/usr/local" | 37 | "/usr/local" |
21 | "/home" | 38 | "/home" |
22 | ) | 39 | ) |
40 | |||
41 | ########################## | ||
42 | # rsnapshot-only setting # | ||
43 | ########################## | ||
44 | |||
45 | # Use the following line to have specific arguments passed to | ||
46 | # rsnapshot such as 'daily' or the like. By default, x200-my uses | ||
47 | # 'alpha', which is already defined in /etc/rsnapshot.conf: | ||
48 | rsnapshot_args="alpha" | ||
diff --git a/x200-my.initd b/x200-my.initd index b026b5b..de88ff0 100644 --- a/x200-my.initd +++ b/x200-my.initd | |||
@@ -14,31 +14,46 @@ extra_started_commands="initbackup" | |||
14 | autobackup="${conf_autobackup}" | 14 | autobackup="${conf_autobackup}" |
15 | backup_path="${conf_backup_path}" | 15 | backup_path="${conf_backup_path}" |
16 | control_file="${conf_control_file}" | 16 | control_file="${conf_control_file}" |
17 | backup_cmd="/usr/bin/rsync" | 17 | if [ $use_rsnapshot = "true" ] |
18 | backup_args="-aAX --relative --delete --quiet" | 18 | then |
19 | backup_cmd="/usr/bin/rsnapshot" | ||
20 | backup_args="${rsnapshot_args}" | ||
21 | else | ||
22 | backup_cmd="/usr/bin/rsync" | ||
23 | backup_args="-aAX --relative --delete --quiet" | ||
24 | fi | ||
19 | 25 | ||
20 | do_listofpackages() { | 26 | do_listofpackages() { |
21 | /usr/bin/pacman -Qqetn > "$backup_path"/pkglist.txt | 27 | /usr/bin/pacman -Qqetn > "$backup_path"/pkglist.txt |
22 | /usr/bin/pacman -Qqem > "$backup_path"/foreignpkglist.txt | 28 | /usr/bin/pacman -Qqem > "$backup_path"/foreignpkglist.txt |
23 | } | 29 | } |
24 | 30 | ||
25 | initbackup() { | 31 | do_backup () { |
26 | if [ $autobackup = "true" ] | 32 | if [ $autobackup = "true" ] |
27 | then | 33 | then |
28 | if [ -e "$backup_path"/"$control_file" ] | 34 | if [ -e "$backup_path"/"$control_file" ] |
29 | then | 35 | then |
30 | do_listofpackages | 36 | do_listofpackages |
31 | for dir in "${conf_backup_dirs[@]}" | 37 | if [ $use_rsnapshot = "true" ] |
32 | do | 38 | then |
33 | if [ -d "$dir" ] | 39 | $backup_cmd $backup_args |
34 | then | 40 | else |
35 | $backup_cmd $backup_args "$dir" "$backup_path" | 41 | for dir in "${conf_backup_dirs[@]}" |
36 | fi | 42 | do |
37 | done | 43 | if [ -d "$dir" ] |
44 | then | ||
45 | $backup_cmd $backup_args "$dir" "$backup_path" | ||
46 | fi | ||
47 | done | ||
48 | fi | ||
38 | fi | 49 | fi |
39 | fi | 50 | fi |
40 | } | 51 | } |
41 | 52 | ||
53 | initbackup() { | ||
54 | do_backup | ||
55 | } | ||
56 | |||
42 | start() { | 57 | start() { |
43 | if [ "${RC_CMD}" = "restart" ]; | 58 | if [ "${RC_CMD}" = "restart" ]; |
44 | then | 59 | then |
@@ -50,18 +65,5 @@ start() { | |||
50 | 65 | ||
51 | stop() { | 66 | stop() { |
52 | /usr/bin/nmcli radio all off | 67 | /usr/bin/nmcli radio all off |
53 | if [ $autobackup = "true" ] | 68 | do_backup |
54 | then | ||
55 | if [ -e "$backup_path"/"$control_file" ] | ||
56 | then | ||
57 | do_listofpackages | ||
58 | for dir in "${conf_backup_dirs[@]}" | ||
59 | do | ||
60 | if [ -d "$dir" ] | ||
61 | then | ||
62 | $backup_cmd $backup_args "$dir" "$backup_path" | ||
63 | fi | ||
64 | done | ||
65 | fi | ||
66 | fi | ||
67 | } | 69 | } |