#!/bin/sh set -Eeuxo pipefail target_path="/persist" snapshot_path="$target_path/kopia-backup-snapshot" if [ -e "$snapshot_path" ] && btrfs subvolume delete "$snapshot_path"; then echo "Deleted leftover old snapshot." fi btrfs subvolume snapshot -r "$target_path" "$snapshot_path" # --no-send-snapshot-path due to https://github.com/kopia/kopia/issues/4402 kopia snapshot create --no-send-snapshot-report --override-source "$target_path" "$@" -- "$snapshot_path" btrfs subvolume delete "$snapshot_path"