From 3ff373498bf1258671315ebe82fe68be66bf1bd7 Mon Sep 17 00:00:00 2001 From: bom Date: Fri, 12 Nov 2021 11:52:47 +0100 Subject: [PATCH] fixed local names --- .../docker/image/resources/file-functions.sh | 52 +++++++------- .../docker/image/resources/pg-functions.sh | 70 +++++++++---------- 2 files changed, 61 insertions(+), 61 deletions(-) diff --git a/infrastructure/docker/image/resources/file-functions.sh b/infrastructure/docker/image/resources/file-functions.sh index 90abccf..a02b190 100644 --- a/infrastructure/docker/image/resources/file-functions.sh +++ b/infrastructure/docker/image/resources/file-functions.sh @@ -5,9 +5,9 @@ function init-file-repo() { if [ -z ${CERTIFICATE_FILE} ]; then - ${command} --cacert ${CERTIFICATE_FILE} + ${command} else - ${command} + ${command} --cacert ${CERTIFICATE_FILE} fi } @@ -15,19 +15,19 @@ function init-file-repo() { function backup-directory() { local directory="$1"; shift - local command-unlock="restic -v -r ${RESTIC_REPOSITORY}/files unlock --cleanup-cache" - local command-backup="cd ${directory} && restic -v -r ${RESTIC_REPOSITORY}/files backup ." - local command-forget="restic -v -r ${RESTIC_REPOSITORY}/files forget --keep-last 1 --keep-within ${RESTIC_DAYS_TO_KEEP}d --prune" + local command_unlock="restic -v -r ${RESTIC_REPOSITORY}/files unlock --cleanup-cache" + local command_backup="cd ${directory} && restic -v -r ${RESTIC_REPOSITORY}/files backup ." + local command_forget="restic -v -r ${RESTIC_REPOSITORY}/files forget --keep-last 1 --keep-within ${RESTIC_DAYS_TO_KEEP}d --prune" if [ -z ${CERTIFICATE_FILE} ]; then - ${command-unlock} --cacert ${CERTIFICATE_FILE} - ${command-backup} --cacert ${CERTIFICATE_FILE} - ${command-forget} --cacert ${CERTIFICATE_FILE} + ${command_unlock} + ${command_backup} + ${command_forget} else - ${command-unlock} - ${command-backup} - ${command-forget} + ${command_unlock} --cacert ${CERTIFICATE_FILE} + ${command_backup} --cacert ${CERTIFICATE_FILE} + ${command_forget} --cacert ${CERTIFICATE_FILE} fi } @@ -35,19 +35,19 @@ function backup-directory() { function backup-fs-from-directory() { local directory="$1"; shift - local command-unlock="restic -v -r ${RESTIC_REPOSITORY}/files unlock --cleanup-cache" - local command-backup="cd ${directory} && restic -v -r ${RESTIC_REPOSITORY}/files backup $@" - local command-forget="restic -v -r ${RESTIC_REPOSITORY}/files forget --keep-last 1 --keep-within ${RESTIC_DAYS_TO_KEEP}d --prune" + local command_unlock="restic -v -r ${RESTIC_REPOSITORY}/files unlock --cleanup-cache" + local command_backup="cd ${directory} && restic -v -r ${RESTIC_REPOSITORY}/files backup $@" + local command_forget="restic -v -r ${RESTIC_REPOSITORY}/files forget --keep-last 1 --keep-within ${RESTIC_DAYS_TO_KEEP}d --prune" if [ -z ${CERTIFICATE_FILE} ]; then - ${command-unlock} --cacert ${CERTIFICATE_FILE} - ${command-backup} --cacert ${CERTIFICATE_FILE} - ${command-forget} --cacert ${CERTIFICATE_FILE} + ${command_unlock} + ${command_backup} + ${command_forget} else - ${command-unlock} - ${command-backup} - ${command-forget} + ${command_unlock} --cacert ${CERTIFICATE_FILE} + ${command_backup} --cacert ${CERTIFICATE_FILE} + ${command_forget} --cacert ${CERTIFICATE_FILE} fi } @@ -55,18 +55,18 @@ function backup-fs-from-directory() { function restore-directory() { local directory="$1"; shift - local command-unlock="restic -v -r ${RESTIC_REPOSITORY}/files unlock --cleanup-cache" - local command-restore="restic -v -r $RESTIC_REPOSITORY/files restore latest --target ${directory}" + local command_unlock="restic -v -r ${RESTIC_REPOSITORY}/files unlock --cleanup-cache" + local command_restore="restic -v -r $RESTIC_REPOSITORY/files restore latest --target ${directory}" if [ -z ${CERTIFICATE_FILE} ]; then - ${command-unlock} --cacert ${CERTIFICATE_FILE} + ${command_unlock} rm -rf ${directory}* - ${command-restore} --cacert ${CERTIFICATE_FILE} + ${command_restore} else - ${command-unlock} + ${command_unlock} --cacert ${CERTIFICATE_FILE} rm -rf ${directory}* - ${command-restore} + ${command_restore} --cacert ${CERTIFICATE_FILE} fi } \ No newline at end of file diff --git a/infrastructure/docker/image/resources/pg-functions.sh b/infrastructure/docker/image/resources/pg-functions.sh index f0e7885..87209f2 100644 --- a/infrastructure/docker/image/resources/pg-functions.sh +++ b/infrastructure/docker/image/resources/pg-functions.sh @@ -4,9 +4,9 @@ function init-role-repo() { if [ -z ${CERTIFICATE_FILE} ]; then - ${command} --cacert ${CERTIFICATE_FILE} + ${command} else - ${command} + ${command} --cacert ${CERTIFICATE_FILE} fi } @@ -16,9 +16,9 @@ function init-database-repo() { if [ -z ${CERTIFICATE_FILE} ]; then - ${command} --cacert ${CERTIFICATE_FILE} + ${command} else - ${command} + ${command} --cacert ${CERTIFICATE_FILE} fi } @@ -40,71 +40,71 @@ function create-pg-pass() { function backup-roles() { local role_prefix="$1"; shift - local command-unlock="restic -v -r ${RESTIC_REPOSITORY}/pg-role unlock --cleanup-cache" - local command-pg-dump="pg_dumpall -h ${POSTGRES_SERVICE} -p ${POSTGRES_PORT} -U${POSTGRES_USER} --no-password --roles-only | \ - grep "${role_prefix}" | \ + local command_unlock="restic -v -r ${RESTIC_REPOSITORY}/pg-role unlock --cleanup-cache" + local command_pg_dump="pg_dumpall -h ${POSTGRES_SERVICE} -p ${POSTGRES_PORT} -U${POSTGRES_USER} --no-password --roles-only | \ + grep ${role_prefix} | \ restic -r ${RESTIC_REPOSITORY}/pg-role backup --stdin" - local command-forget="restic -v -r ${RESTIC_REPOSITORY}/pg-role forget --keep-last 1 --keep-within ${RESTIC_DAYS_TO_KEEP}d --prune" + local command_forget="restic -v -r ${RESTIC_REPOSITORY}/pg-role forget --keep-last 1 --keep-within ${RESTIC_DAYS_TO_KEEP}d --prune" if [ -z ${CERTIFICATE_FILE} ]; then - ${command-unlock} --cacert ${CERTIFICATE_FILE} - ${command-pg-dump} --cacert ${CERTIFICATE_FILE} - ${command-forget} --cacert ${CERTIFICATE_FILE} + ${command_unlock} + ${command_pg_dump} + ${command_forget} else - ${command-unlock} - ${command-pg-dump} - ${command-forget} + ${command_unlock} --cacert ${CERTIFICATE_FILE} + ${command_pg_dump} --cacert ${CERTIFICATE_FILE} + ${command_forget} --cacert ${CERTIFICATE_FILE} fi } function backup-db-dump() { - local command-unlock="restic -v -r ${RESTIC_REPOSITORY}/pg-database unlock --cleanup-cache" - local command-pg-dump="pg_dump -d ${POSTGRES_DB} -h ${POSTGRES_SERVICE} -p ${POSTGRES_PORT} \ + local command_unlock="restic -v -r ${RESTIC_REPOSITORY}/pg-database unlock --cleanup-cache" + local command_pg_dump="pg_dump -d ${POSTGRES_DB} -h ${POSTGRES_SERVICE} -p ${POSTGRES_PORT} \ -U ${POSTGRES_USER} --no-password --serializable-deferrable | \ restic -r ${RESTIC_REPOSITORY}/pg-database backup --stdin" - local command-forget="restic -v -r ${RESTIC_REPOSITORY}/pg-database forget --keep-last 1 --keep-within ${RESTIC_DAYS_TO_KEEP}d --prune" + local command_forget="restic -v -r ${RESTIC_REPOSITORY}/pg-database forget --keep-last 1 --keep-within ${RESTIC_DAYS_TO_KEEP}d --prune" if [ -z ${CERTIFICATE_FILE} ]; then - ${command-unlock} --cacert ${CERTIFICATE_FILE} - ${command-pg-dump} --cacert ${CERTIFICATE_FILE} - ${command-forget} --cacert ${CERTIFICATE_FILE} + ${command_unlock} + ${command_pg_dump} + ${command_forget} else - ${command-unlock} - ${command-pg-dump} - ${command-forget} + ${command_unlock} --cacert ${CERTIFICATE_FILE} + ${command_pg_dump} --cacert ${CERTIFICATE_FILE} + ${command_forget} --cacert ${CERTIFICATE_FILE} fi } function restore-roles() { - local command-unlock="restic -v -r ${RESTIC_REPOSITORY}/pg-role unlock --cleanup-cache" - local command-pg-dump="restic -r ${RESTIC_REPOSITORY}/pg-role dump latest stdin | \ + local command_unlock="restic -v -r ${RESTIC_REPOSITORY}/pg-role unlock --cleanup-cache" + local command_pg_dump="restic -r ${RESTIC_REPOSITORY}/pg-role dump latest stdin | \ psql -d template1 -h ${POSTGRES_SERVICE} -p ${POSTGRES_PORT} -U ${POSTGRES_USER} \ --no-password" if [ -z ${CERTIFICATE_FILE} ]; then - ${command-unlock} --cacert ${CERTIFICATE_FILE} - ${command-pg-dump} --cacert ${CERTIFICATE_FILE} + ${command_unlock} + ${command_pg-dump} else - ${command-unlock} - ${command-pg-dump} + ${command_unlock} --cacert ${CERTIFICATE_FILE} + ${command_pg_dump} --cacert ${CERTIFICATE_FILE} fi } function restore-db() { - local command-unlock="restic -v -r ${RESTIC_REPOSITORY}/pg-database unlock --cleanup-cache" - local command-pg-dump="restic -r ${RESTIC_REPOSITORY}/pg-database dump latest stdin | \ + local command_unlock="restic -v -r ${RESTIC_REPOSITORY}/pg-database unlock --cleanup-cache" + local command_pg_dump="restic -r ${RESTIC_REPOSITORY}/pg_database dump latest stdin | \ psql -d ${POSTGRES_DB} -h ${POSTGRES_SERVICE} -p ${POSTGRES_PORT} -U ${POSTGRES_USER} \ --no-password" if [ -z ${CERTIFICATE_FILE} ]; then - ${command-unlock} --cacert ${CERTIFICATE_FILE} - ${command-pg-dump} --cacert ${CERTIFICATE_FILE} + ${command_unlock} + ${command_pg_dump} else - ${command-unlock} - ${command-pg-dump} + ${command_unlock} --cacert ${CERTIFICATE_FILE} + ${command_pg_dump} --cacert ${CERTIFICATE_FILE} fi } \ No newline at end of file