diff --git a/README.md b/README.md index 9e54e8b..5188eb4 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,9 @@ place. Example: The timer included is weekly. Edit both files to your taste. +You can exclude a configuration from backup by setting `SNAP_SYNC_EXCLUDE=yes` +in your snapper configuration file. + ## Example command line usage ### No arguments diff --git a/bin/snap-sync b/bin/snap-sync index bfd53d2..d2bdd7e 100755 --- a/bin/snap-sync +++ b/bin/snap-sync @@ -135,6 +135,8 @@ selected_configs=${selected_configs:-$SNAPPER_CONFIGS} # Initial configuration of where backup directories are for x in $selected_configs; do + SNAP_SYNC_EXCLUDE=no + if [[ -f "/etc/snapper/configs/$x" ]]; then source /etc/snapper/configs/$x else @@ -142,6 +144,10 @@ for x in $selected_configs; do exit 1 fi + if [[ $SNAP_SYNC_EXCLUDE == "yes" ]]; then + continue + fi + old_num=$(snapper -c "$x" list -t single | awk '/'"$selected_uuid"'/ {print $1}') old_snap=$SUBVOLUME/.snapshots/$old_num/snapshot @@ -166,7 +172,7 @@ done # Actual backing up for x in $selected_configs; do - printf "\n" + SNAP_SYNC_EXCLUDE=no if [[ -f "/etc/snapper/configs/$x" ]]; then source /etc/snapper/configs/$x @@ -175,6 +181,12 @@ for x in $selected_configs; do exit 1 fi + if [[ $SNAP_SYNC_EXCLUDE == "yes" ]]; then + continue + fi + + printf "\n" + old_num=$(snapper -c "$x" list -t single | awk '/'"$selected_uuid"'/ {print $1}') old_snap=$SUBVOLUME/.snapshots/$old_num/snapshot