Skip to content

Commit 30b4db1

Browse files
committed
Check if destination already exists.
If so, abort that configuration's backup and warn user that manual intervention is required. Fixes #54.
1 parent a735dd8 commit 30b4db1

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

bin/snap-sync

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,12 @@ for x in $selected_configs; do
421421
new_info="${NEW_INFO_ARRAY[$i]}"
422422
backup_location="${BACKUPLOC_ARRAY[$i]}"
423423

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

426432
if [[ -z "$old_num" ]]; then
@@ -434,6 +440,7 @@ for x in $selected_configs; do
434440
# backup location. Using the -c flag instead of -p tells it that there
435441
# is an identical subvolume to the old snapshot at the receiving
436442
# location where it can get its data. This helps speed up the transfer.
443+
437444
btrfs send -c "$old_snap" "$new_snap" | $ssh btrfs receive "$backup_location"
438445
printf "Modifying data for old snapshot for %s...\n" "$x" | tee $PIPE
439446
snapper -v -c "$x" modify -d "old snap-sync snapshot (you may remove)" -u "backupdir=,subvolid=,uuid=" -c "number" "$old_num"

0 commit comments

Comments
 (0)