summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2023-05-19 15:37:16 -0400
committerAndrew Cady <d@jerkface.net>2023-05-19 15:37:16 -0400
commitbc8450ee096c358c61f1911b677c9ff77df51913 (patch)
treee624b79be4b9984d15ef8bbde987d0d02fba9b47
initial
-rwxr-xr-xgo.sh20
1 files changed, 20 insertions, 0 deletions
diff --git a/go.sh b/go.sh
new file mode 100755
index 0000000..4a9ff6f
--- /dev/null
+++ b/go.sh
@@ -0,0 +1,20 @@
1#!/bin/bash
2set -e
3wd=/root/src/local-btrfs-backup
4src=/
5dst=/srv/sdm1/borges
6parent_file=$wd/last-parent.txt
7
8snapshot="${src%/}"/backup~$(date -Ins)
9
10set -x
11if [ -e "$parent_file" ]
12then
13 read parent < "$parent_file"
14fi
15
16btrfs subvolume snapshot -r "$src" "$snapshot"
17btrfs send "$snapshot" ${parent:+ -p "$parent"} | pv | btrfs receive "$dst"
18printf "%s\n" "$snapshot" > "$parent_file"~tmp
19mv -T -- "$parent_file"~tmp "$parent_file"
20