add check if source snap exists on source dataset
This commit is contained in:
parent
a09da0ced5
commit
9678729356
1 changed files with 8 additions and 3 deletions
|
@ -31,17 +31,21 @@ backups_server_zfs_snapshots=$(ssh -$backup_server_ipv -p $backup_server_port $b
|
|||
for dataset in $source_datasets;
|
||||
do
|
||||
|
||||
source_snap=$(echo "$source_zfs_snapshots" | grep "$dataset"@ | grep -E "....-..-.._........--"$zfsnap_days_keep_snaps"d" | tail -n1 | cut -d"@" -f2 | cut -d" " -f1)
|
||||
dataset_clean=$(echo $dataset | grep -o '[^/]*$')
|
||||
source_snap=$(echo "$source_zfs_snapshots" | grep "$dataset"@ | grep -E "....-..-.._........--"$zfsnap_days_keep_snaps"d" | tail -n1 | cut -d"@" -f2 | cut -d" " -f1)
|
||||
source_snaps=$(echo "$source_zfs_snapshots" | grep "$dataset"@ | grep -E "....-..-.._........--"$zfsnap_days_keep_snaps"d" | cut -d"@" -f2 | cut -d" " -f1)
|
||||
backup_snap=$(echo "$backups_server_zfs_snapshots" | grep "$backup_server_dataset"/"$dataset_clean"@ | grep -E "....-..-.._........--"$zfsnap_days_keep_snaps"d" | tail -n1 | cut -d"@" -f2 | cut -d" " -f1)
|
||||
backup_snaps=$(echo "$backups_server_zfs_snapshots" | grep "$backup_server_dataset"/"$dataset_clean"@ | grep -E "....-..-.._........--"$zfsnap_days_keep_snaps"d" | cut -d"@" -f2 | cut -d" " -f1)
|
||||
source_backups_server_match=$(grep -Fxf <(echo "$source_snaps") <(echo "$backup_snaps"))
|
||||
source_backups_server_match_tailed=$(echo "$source_backups_server_match" | tail -n1)
|
||||
|
||||
if [ -z "$backup_snap" ]
|
||||
then
|
||||
echo "Snapshot on backup server not found, sending "$dataset"@"$source_snap" to server "$backup_server" "$backup_server_dataset"/"$dataset_clean""
|
||||
zfs send -c "$dataset"@"$source_snap" | pv -L "$shape_megabytes"m | ssh -$backup_server_ipv "$backup_server" -p "$backup_server_port" zfs recv "$backup_server_dataset"/"$dataset_clean" && echo "Send OK"
|
||||
else
|
||||
echo "Snapshot on backup server found, sending incremental from "$dataset"@"$backup_snap" to "$dataset"@"$source_snap" to server "$backup_server" "$backup_server_dataset"/"$dataset_clean""
|
||||
zfs send -ci "$dataset"@"$backup_snap" "$dataset"@"$source_snap" | pv -L "$shape_megabytes"m | ssh -$backup_server_ipv "$backup_server" -p "$backup_server_port" zfs recv "$backup_server_dataset"/"$dataset_clean" -F && echo "Send OK"
|
||||
echo "Snapshot on backup server found, sending incremental from "$dataset"@"$source_backups_server_match_tailed" to "$dataset"@"$source_snap" to server "$backup_server" "$backup_server_dataset"/"$dataset_clean""
|
||||
zfs send -ci "$dataset"@"$source_backups_server_match_tailed" "$dataset"@"$source_snap" | pv -L "$shape_megabytes"m | ssh -$backup_server_ipv "$backup_server" -p "$backup_server_port" zfs recv "$backup_server_dataset"/"$dataset_clean" -F && echo "Send OK"
|
||||
fi
|
||||
done
|
||||
del_snaps_block
|
||||
|
@ -51,6 +55,7 @@ del_snaps_block () {
|
|||
if [ $backup_server_delete_old_snaps = "y" ]; then
|
||||
for dataset in $source_datasets;
|
||||
do
|
||||
|
||||
dataset_clean=$(echo $dataset | grep -o '[^/]*$')
|
||||
snaps_to_delete=$(echo "$backups_server_zfs_snapshots" | grep "$backup_server_dataset"/"$dataset_clean"@ | grep -E "....-..-.._........--"$zfsnap_days_keep_snaps"d" | head -n -"$backup_server_number_keep_snaps" | cut -d" " -f1)
|
||||
|
||||
|
|
Loading…
Reference in a new issue