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