WIP: kopia backup script

This commit is contained in:
2025-03-11 10:18:24 +00:00
parent bbdb2bf1ff
commit 6165d4a2af
4 changed files with 32 additions and 4 deletions

View File

@@ -1,6 +1,6 @@
{ pkgs, ... }:
{
environment.systemPackages = [ pkgs.kopia ];
environment.systemPackages = [ pkgs.unstable.kopia ];
# systemd = {
# services = {

View File

@@ -0,0 +1,17 @@
#!/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"