#!/bin/sh set -eu echo "running backup job" date -Iminutes if [ ! -d ~/.ssh ]; then echo "error: $(realpath ~/.ssh) directory does not exist"; exit 1; fi host_ip=$(ip r | head -1 | cut -d' ' -f3 | tr -d '\n') host=root@"$host_ip" remote=root@truenas.lab.home if ! ssh -q "$host" exit; then echo "error: not able to ssh into host of container $host"; exit 1; fi if ! ssh -q "$remote" exit; then echo "error: not able to ssh into backup remote $remote"; exit 1; fi hostname=$(ssh "$host" hostname | tr -d '\n') remote_dataset=Mass-Storage-New/Backup/$hostname zfs_prop_name="nas" # autobackup:nas = true zfs-autobackup \ --snapshot-format "{}_%Y-%m-%d_%H-%M_%S" \ --encrypt \ --ssh-source "$host" \ --ssh-target "$remote" \ "$zfs_prop_name" \ "$remote_dataset" echo "ran backup job" date -Iminutes