From 79bae2d82790d8334e3b91302ffc243206489c54 Mon Sep 17 00:00:00 2001 From: Les De Ridder Date: Wed, 8 Jun 2016 16:05:56 +0000 Subject: [PATCH] Add lock files --- backup.fish | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/backup.fish b/backup.fish index 49c8f6f..475a094 100755 --- a/backup.fish +++ b/backup.fish @@ -19,9 +19,16 @@ for pair in (get-subvol-mounts) set safepath $subvoldir/$safename if test -d $safepath - sudo btrfs subvolume snapshot -r $mount $safepath-new + if not test -f $mount/.btrfish-lock + sudo btrfs subvolume snapshot -r $mount $safepath-new - set snapshots $snapshots $safepath + sudo touch $mount/.btrfish-lock + + set snapshots $snapshots $safepath + set pairs $pairs $pair + else + echo "$mount/.btrfish-lock exists, skipping..." + end else echo $mount "is not bootstrapped and will not be included in the backups!" end @@ -42,13 +49,13 @@ for snapshot in $snapshots end echo "Renaming subvolumes on target..." -for pair in (get-subvol-mounts) +for pair in $pairs set subvol (clean-name (get-subvol $pair)) - if test -d $subvoldir/$subvol - rename-target-subvolume $subvol $subvol.(date +%Y-%m-%d) - rename-target-subvolume $subvol-new $subvol - end + rename-target-subvolume $subvol $subvol.(date +%Y-%m-%d) + rename-target-subvolume $subvol-new $subvol + + sudo rm (get-mount $pair)/.btrfish-lock end echo "Done!"