From 867df0cf3d06a789a92c0c7a012393a5e1a89369 Mon Sep 17 00:00:00 2001 From: Robert Alessi Date: Sun, 15 Dec 2019 15:22:34 +0100 Subject: optionally use rsnapshot to have incremental backups --- PKGBUILD | 9 +++++---- x200-my.confd | 38 ++++++++++++++++++++++++++++++++------ x200-my.initd | 50 ++++++++++++++++++++++++++------------------------ 3 files changed, 63 insertions(+), 34 deletions(-) diff --git a/PKGBUILD b/PKGBUILD index 8e64cb2..bc17e95 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -1,21 +1,22 @@ # Maintainer: Robert Alessi pkgname=x200-my -pkgver=0.3.1 +pkgver=0.4 pkgrel=1 pkgdesc="Service to remove whining noise from Thinkpads X200, power off the wifi on shutdown and optionally backup directories." arch=(any) license=(GPL2) url="http://git.robertalessi.net/x200-my" -depends=('sysvinit' 'networkmanager' 'acpid' 'intel-gpu-tools') +depends=('sysvinit' 'networkmanager' 'acpid' 'intel-gpu-tools' 'rsync') +optdepends=('rsnapshot: for incremental backups') install=x200-my.install source=('x200-my.initd' 'x200-my.confd' 'x200-my-lid.sh' 'x200-my-sleep.sh' 'x200-my.sh') -sha512sums=('96579d18e8639da441b2f0104e453f2ffd34a1c14c77ad08709fc090b168d0030f5074d8c54f116739a4f421286c5d2b64181c66fabd2eee91c371d8aa856395' - 'd181ca58ffed55d7d35bd78d2ace09e6c459938f7f7c6cb10feff56de23861feef8b859fde9bb895021efb840a1fe0d3aef7861c7881bb9a793cf9491a2fd17d' +sha512sums=('40d74cc2bce559cc2a08ebcd707279e148d802a5cdeb675cfb5c3abfed453378028a9f78b1be31269d908ad6aacaaaf53b48b13f97d019cdb73156ff92f507b5' + 'bf6513589b39daad03e4365e61f2026a4cb1801af9d061f38f502c4caa5732d03e529d43f2ec87a4ded952b6a299fdec1c18f302162b0dd28c540299be8987cf' '0dc141f1a26f2cd570d49a05bcc9496ba4c49fde39afad46f5a0783e83c07ec810ca81454a28c3241bcffc62ac31274e2a8d726bbd3c1e91d8cf5315b783c3f8' '610564aa853c5dbc4e370ec2a4d3b5590e53ed235a1960927c0986a31f6c77d135086b1f5752b56fd511ea4a0294082fc7e98ee2fa7b69b37776a59f45c2ec34' '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 @@ PWMFREQ_RATE="0x8bb7b16dc5b6a" -# -# Backup options -# -# Activate autobackup on shutdown (true/false) +################## +# Backup options # +################## + +# Activate autobackup on shutdown (true/false)? conf_autobackup="false" -# Path to backup directory: -conf_backup_path="/mnt/disk" +# Use rsnaphot (true/false)? 'false' means 'use rsync': +use_rsnapshot="false" + +############################ +# rsync/rsnapshot settings # +############################ + +# Path to backup directory (note that rsnapshot additionally needs +# this to be specified as 'snapshot_root' in /etc/rsnapshot.conf): +conf_backup_path="/mnt/disk/snapshots" + +# The following option applies both to rsync and rsnapshot. # Control file. This (empty) file must exist in the backup directory: conf_control_file="dobackup" + +###################### +# rsync-only setting # +###################### + +# rsync only option: # Directories to backup: conf_backup_dirs=( "/etc" @@ -20,3 +37,12 @@ conf_backup_dirs=( "/usr/local" "/home" ) + +########################## +# rsnapshot-only setting # +########################## + +# Use the following line to have specific arguments passed to +# rsnapshot such as 'daily' or the like. By default, x200-my uses +# 'alpha', which is already defined in /etc/rsnapshot.conf: +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" autobackup="${conf_autobackup}" backup_path="${conf_backup_path}" control_file="${conf_control_file}" -backup_cmd="/usr/bin/rsync" -backup_args="-aAX --relative --delete --quiet" +if [ $use_rsnapshot = "true" ] +then + backup_cmd="/usr/bin/rsnapshot" + backup_args="${rsnapshot_args}" +else + backup_cmd="/usr/bin/rsync" + backup_args="-aAX --relative --delete --quiet" +fi do_listofpackages() { /usr/bin/pacman -Qqetn > "$backup_path"/pkglist.txt /usr/bin/pacman -Qqem > "$backup_path"/foreignpkglist.txt } -initbackup() { +do_backup () { if [ $autobackup = "true" ] then if [ -e "$backup_path"/"$control_file" ] then do_listofpackages - for dir in "${conf_backup_dirs[@]}" - do - if [ -d "$dir" ] - then - $backup_cmd $backup_args "$dir" "$backup_path" - fi - done + if [ $use_rsnapshot = "true" ] + then + $backup_cmd $backup_args + else + for dir in "${conf_backup_dirs[@]}" + do + if [ -d "$dir" ] + then + $backup_cmd $backup_args "$dir" "$backup_path" + fi + done + fi fi fi } +initbackup() { + do_backup +} + start() { if [ "${RC_CMD}" = "restart" ]; then @@ -50,18 +65,5 @@ start() { stop() { /usr/bin/nmcli radio all off - if [ $autobackup = "true" ] - then - if [ -e "$backup_path"/"$control_file" ] - then - do_listofpackages - for dir in "${conf_backup_dirs[@]}" - do - if [ -d "$dir" ] - then - $backup_cmd $backup_args "$dir" "$backup_path" - fi - done - fi - fi + do_backup } -- cgit v1.2.3