Skip to content

Commit

Permalink
Check if destination already exists.
Browse files Browse the repository at this point in the history
If so, abort that configuration's backup and warn user that
manual intervention is required.

Fixes #54.
  • Loading branch information
wesbarnett committed May 25, 2018
1 parent a735dd8 commit 30b4db1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions bin/snap-sync
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,12 @@ for x in $selected_configs; do
new_info="${NEW_INFO_ARRAY[$i]}"
backup_location="${BACKUPLOC_ARRAY[$i]}"

if ($ssh test -d "$backup_location/snapshot") ; then
printf "ERROR: Backup directory '%s' already exists. Skipping backup of this configuration!\n" "$backup_location/snapshot" | tee $PIPE
printf "Move or delete destination directory and try backup again.\n" | tee $PIPE
continue
fi

$ssh mkdir -p $backup_location

if [[ -z "$old_num" ]]; then
Expand All @@ -434,6 +440,7 @@ for x in $selected_configs; do
# backup location. Using the -c flag instead of -p tells it that there
# is an identical subvolume to the old snapshot at the receiving
# location where it can get its data. This helps speed up the transfer.

btrfs send -c "$old_snap" "$new_snap" | $ssh btrfs receive "$backup_location"
printf "Modifying data for old snapshot for %s...\n" "$x" | tee $PIPE
snapper -v -c "$x" modify -d "old snap-sync snapshot (you may remove)" -u "backupdir=,subvolid=,uuid=" -c "number" "$old_num"
Expand Down

0 comments on commit 30b4db1

Please sign in to comment.