summaryrefslogtreecommitdiff
path: root/roles/storage/zfs/syncoid/templates/syncoid_pull.j2
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2022-01-11 00:04:35 +0100
committerChristian Pointner <equinox@spreadspace.org>2022-01-11 00:04:35 +0100
commit5f3230aad459d06cfd257616564bddc4cd9ad7cc (patch)
tree62987e7d565077a7a8aee4f7460bb1b4789d9158 /roles/storage/zfs/syncoid/templates/syncoid_pull.j2
parentdisable syncoid for some testvms (diff)
zfs/syncoid: add error handling to pull
Diffstat (limited to 'roles/storage/zfs/syncoid/templates/syncoid_pull.j2')
-rw-r--r--roles/storage/zfs/syncoid/templates/syncoid_pull.j229
1 files changed, 29 insertions, 0 deletions
diff --git a/roles/storage/zfs/syncoid/templates/syncoid_pull.j2 b/roles/storage/zfs/syncoid/templates/syncoid_pull.j2
new file mode 100644
index 00000000..ab6c3116
--- /dev/null
+++ b/roles/storage/zfs/syncoid/templates/syncoid_pull.j2
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ] || [ "$1" == "--" ] || [ "$2" == "--" ] || [ "$3" == "--" ]; then
+ echo "$0 <src-host> <src-path> <dest-path> [ -- <additional syncoid arguments .. > ]"
+ exit 1
+fi
+src_host=$1
+src_path=$2
+dest_path=$3
+shift 3
+if [ -n "$1" ]; then
+ if [ "$1" != "--" ]; then
+ echo "additional arguments must be separated using '--'"
+ exit 1
+ fi
+ shift
+fi
+
+/usr/sbin/syncoid --sshoption "UserKnownHostsFile=/var/lib/syncoid/ssh.knownhosts" --sshoption "HashKnownHosts=no" --sshkey "/var/lib/syncoid/id_ssh_ed25519" --no-sync-snap --compress zstd-fast "$@" "$src_host:$src_path" "$dest_path"
+ret=$?
+
+if [ -n "$RUNTIME_DIRECTORY" ]; then
+ cat <<EOF >> "$RUNTIME_DIRECTORY/metrics"
+syncoid_pull_exit_code{backup_server="{{ inventory_hostname }}",source="$src_path",destination="$dest_path"} $ret
+EOF
+ echo $ret >> "$RUNTIME_DIRECTORY/exit_codes"
+fi
+
+exit $ret