summaryrefslogtreecommitdiff
path: root/src/btrfs-send-root.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/btrfs-send-root.sh')
-rw-r--r--src/btrfs-send-root.sh45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/btrfs-send-root.sh b/src/btrfs-send-root.sh
new file mode 100644
index 0000000..8a3a513
--- /dev/null
+++ b/src/btrfs-send-root.sh
@@ -0,0 +1,45 @@
1#!/bin/sh
2. samizdat-paths.sh
3. var.sh
4. btrfs-functions.sh
5
6rootfs_uuid ()
7{
8 btrfs filesystem show / | sed -ne 's/.*uuid: //p'
9}
10
11remote_btrfs_receiver()
12{
13# ssh "$BTRFS_RECEIVE_DESTINATION_HOST" -- "sudo btrfs receive $(shellescape "$BTRFS_RECEIVE_DESTINATION_PATH")"
14 ssh "$BTRFS_RECEIVE_DESTINATION_HOST" -- \
15 "sudo sh sami/btrfs-receive-root.sh $(shellescape "$BTRFS_RECEIVE_DESTINATION_PATH") $(shellescape "$BTRFS_RECEIVE_SUBVOLUME_NAME")"
16}
17
18dummy_receiver()
19{
20 true
21}
22
23push_remote()
24{
25 $(ARGS_NE mnt src ssh_dst)
26
27 now=$(date +%F.%H%M%S) || die
28 snap_dir=$mnt/snapshot.$now
29 prev_dir=$mnt/SEED
30
31 case "$ssh_dst" in
32 *:*) ;;
33 *) return 1;;
34 esac
35 local BTRFS_RECEIVE_DESTINATION_PATH="${ssh_dst#*:}"
36 local BTRFS_RECEIVE_DESTINATION_HOST="${ssh_dst%%:*}"
37 local BTRFS_RECEIVE_SUBVOLUME_NAME="${snap_dir#$mnt/}"
38 push_helper false "$snap_dir" "$prev_dir" "$src" remote_btrfs_receiver
39}
40
41ssh_dst=d@fifty.local:sami/test_dest
42
43mkdir -p /mnt/rootfs || die
44mountpoint -q /mnt/rootfs || mount -o subvol=/ UUID=$(rootfs_uuid) /mnt/rootfs || die
45push_remote /mnt/rootfs / "$ssh_dst"