From 6bae9c00440f26e4ad61a5158d118cd66a6bb099 Mon Sep 17 00:00:00 2001 From: James Barnett Date: Sat, 23 Apr 2016 08:38:38 -0500 Subject: [PATCH] create simple way to add more configurations to take snapshots of --- snapper-post | 21 ++++++++++++++------- snapper-pre | 9 ++++++++- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/snapper-post b/snapper-post index 02d6bd6..5c6f819 100755 --- a/snapper-post +++ b/snapper-post @@ -20,12 +20,19 @@ # Takes a snapper post snapshot after a pacman transaction +# Change this variable to include other configs in the post snapshot +# You must also change it in the pre snapshot script +CONFIGS="root" +#CONFIGS="root home" + PACMAN_CMD=$(ps -C pacman -o args=) PREFILE=/usr/share/libalpm/hooks.bin/snap-pac/.pre -if [ -f $PREFILE ]; then - SNAPPERPACPRE=$(cat $PREFILE) - snapper --config root create --cleanup-algorithm number --type post --pre-number $SNAPPERPACPRE --description "$PACMAN_CMD" - rm $PREFILE -else - echo "WARNING: $PREFILE does not exist, so not performing post snapshot. If you are initially installing snap-pac, this is normal." -fi +for x in $CONFIGS; do + if [ -f $PREFILE"_"$x ]; then + SNAPPERPACPRE=$(cat $PREFILE"_"$x) + snapper --config $x create --cleanup-algorithm number --type post --pre-number $SNAPPERPACPRE --description "$PACMAN_CMD" + rm $PREFILE"_"$x + else + echo "WARNING: $PREFILE"_"$x does not exist, so not performing post snapshot. If you are initially installing snap-pac, this is normal." + fi +done diff --git a/snapper-pre b/snapper-pre index a1c4aeb..694c923 100755 --- a/snapper-pre +++ b/snapper-pre @@ -20,6 +20,13 @@ # Takes a snapper pre snapshot before a pacman transaction +# Change this variable to include other configs in the pre snapshot +# You must also change it in the post snapshot script +CONFIGS="root" +#CONFIGS="root home" + PACMAN_CMD=$(ps -C pacman -o args=) PREFILE=/usr/share/libalpm/hooks.bin/snap-pac/.pre -snapper --config root create --type pre --cleanup-algorithm number --print-number --description "$PACMAN_CMD" > $PREFILE +for x in $CONFIGS; do + snapper --config $x create --type pre --cleanup-algorithm number --print-number --description "$PACMAN_CMD" > $PREFILE"_"$x +done