Compare commits

..

No commits in common. "428f5a568bcd816f3155b74f45ce3571d40389c2" and "0793aa0d9b5c512a2df800692b9c94091aa436e2" have entirely different histories.

View file

@ -10,23 +10,16 @@ ssh="ssh -o StrictHostKeyChecking=no backup-receiver@$server"
source_dataset=$(zfs list -H -o mountpoint,name | grep -P "^$path\t" | cut -d $'\t' -f 2)
target_dataset="tank/$uuid/$source_dataset"
target_dataset_parent=$(echo $target_dataset | rev | cut -d / -f 2- | rev)
new_bookmark="auto-backup_$(date +"%Y-%m-%d_%H:%M:%S")"
echo "BACKUP ZFS DATASET - PATH: $path, SERVER: $server, UUID: $uuid, SOURCE_DATASET: $source_dataset, TARGET_DATASET: $TARGET_DATASET"
if ! $ssh sudo zfs list -t filesystem -H -o name | grep -q "^$target_dataset_parent$"
then
echo "CREATING PARENT DATASET..."
$ssh sudo zfs create -p -o mountpoint=none "$target_dataset_parent"
fi
zfs snap $source_dataset@$new_bookmark
if zfs list -t bookmark -H -o name | grep '#auto-backup' | wc -l | grep -q "^0$"
then
echo "INITIAL BACKUP"
zfs send -v "$source_dataset@$new_bookmark" | $ssh sudo zfs recv -F $target_dataset
zfs send -v "$source_dataset@$new_bookmark" | $ssh sudo zfs recv $target_dataset
else
echo "INCREMENTAL BACKUP"
last_bookmark=$(zfs list -t bookmark -H -o name | sort | tail -1 | cut -d '#' -f 2)