diff --git a/bundles/backup/files/backup_all b/bundles/backup/files/backup_all index e69de29..0befa35 100644 --- a/bundles/backup/files/backup_all +++ b/bundles/backup/files/backup_all @@ -0,0 +1,6 @@ +#!/bin/bash + +for path in $(jq -r '.paths | .[]' < /etc/backup/config.json) +do + /opt/backup/backup_path "$path" +done diff --git a/bundles/backup/files/backup_path b/bundles/backup/files/backup_path index 8c518be..d9c10d2 100644 --- a/bundles/backup/files/backup_path +++ b/bundles/backup/files/backup_path @@ -4,7 +4,7 @@ path=$1 if zfs list -H -o mountpoint | grep -q "$path" then - /opt/backuo/backup_path_via_zfs "$path" + /opt/backup/backup_path_via_zfs "$path" elif test -d "$path" then /opt/backuo/backup_path_via_rsync "$path" diff --git a/bundles/backup/files/backup_path_via_zfs b/bundles/backup/files/backup_path_via_zfs index 7374a76..816d46c 100644 --- a/bundles/backup/files/backup_path_via_zfs +++ b/bundles/backup/files/backup_path_via_zfs @@ -1,12 +1,11 @@ #!/bin/bash -set -e -set -x +set -exu path=$1 uuid=$(jq -r .client_uuid < /etc/backup/config.json) server=$(jq -r .server_hostname < /etc/backup/config.json) -ssh="ssh -o StrictHostKeyChecking=no backup-receiver@$server" +ssh="ssh -o StrictHostKeyChecking=no -o ConnectTimeout=5 backup-receiver@$server" source_dataset=$(zfs list -H -o mountpoint,name | grep -P "^$path\t" | cut -d $'\t' -f 2) target_dataset="tank/$uuid/$source_dataset" @@ -16,10 +15,12 @@ new_bookmark="$bookmark_prefix$(date +"%Y-%m-%d_%H:%M:%S")" for var in path uuid server ssh source_dataset target_dataset target_dataset_parent new_bookmark do - [[ -z "${!var}" ]] && echo "ERROR - $var is empty" && exit 97 + [[ -z "${!var}" ]] && echo "ERROR - $var is empty" && exit 96 done -echo "BACKUP ZFS DATASET - PATH: $path, SERVER: $server, UUID: $uuid, SOURCE_DATASET: $source_dataset, TARGET_DATASET: $TARGET_DATASET" +$ssh true || (echo "ERROR - cant ssh connect to $server" && exit 97) + +echo "BACKUP ZFS DATASET - PATH: $path, SERVER: $server, UUID: $uuid, SOURCE_DATASET: $source_dataset, TARGET_DATASET: $target_dataset" if ! $ssh sudo zfs list -t filesystem -H -o name | grep -q "^$target_dataset_parent$" then