refactor: Move Backups after the Update
This commit is contained in:
parent
1befa65f35
commit
713dc5f4e9
|
@ -1,37 +1,6 @@
|
|||
#!/bin/bash
|
||||
source lib/functions.sh
|
||||
|
||||
AUTO_BACKUP=${AUTO_BACKUP:-true}
|
||||
|
||||
if [ "$AUTO_BACKUP" == "true" ]; then
|
||||
BACKUP_DIRECTORY="/var/cache/bridgehead/backup"
|
||||
if [ ! -d $BACKUP_DIRECTORY ]; then
|
||||
message="Performing automatic maintenance: Creating Backup directory $BACKUP_DIRECTORY."
|
||||
hc_send log "$message"
|
||||
log INFO "$message"
|
||||
mkdir -p $BACKUP_DIRECTORY
|
||||
fi
|
||||
BACKUP_SERVICES="$(docker ps --filter ancestor=postgres:14-alpine --format "{{.Names}}" | tr "\n" "\ ")"
|
||||
log INFO "Performing automatic maintenance: Creating Backups for $BACKUP_SERVICES";
|
||||
for service in $BACKUP_SERVICES; do
|
||||
if [ ! -d $BACKUP_DIRECTORY/$service ]; then
|
||||
message="Performing automatic maintenance: Creating Backup directory for $service in $BACKUP_DIRECTORY."
|
||||
hc_send log "$message"
|
||||
log INFO "$message"
|
||||
mkdir -p $BACKUP_DIRECTORY/$service
|
||||
fi
|
||||
if createEncryptedPostgresBackup "$BACKUP_DIRECTORY" "$service"; then
|
||||
message="Performing automatic maintenance: Stored encrypted Backup for $service in $BACKUP_DIRECTORY."
|
||||
hc_send log "$message"
|
||||
log INFO "$message"
|
||||
else
|
||||
fail_and_report 5 "Failed to create encrypted update for $service"
|
||||
fi
|
||||
done
|
||||
else
|
||||
log WARN "Automated backups are disabled (variable AUTO_BACKUPS != \"true\")"
|
||||
fi
|
||||
|
||||
AUTO_HOUSEKEEPING=${AUTO_HOUSEKEEPING:-true}
|
||||
|
||||
if [ "$AUTO_HOUSEKEEPING" == "true" ]; then
|
||||
|
@ -134,6 +103,37 @@ else
|
|||
hc_send log "$RES"
|
||||
fi
|
||||
|
||||
AUTO_BACKUP=${AUTO_BACKUP:-true}
|
||||
|
||||
if [ "$AUTO_BACKUP" == "true" ]; then
|
||||
BACKUP_DIRECTORY="/var/cache/bridgehead/backup"
|
||||
if [ ! -d $BACKUP_DIRECTORY ]; then
|
||||
message="Performing automatic maintenance: Creating Backup directory $BACKUP_DIRECTORY."
|
||||
hc_send log "$message"
|
||||
log INFO "$message"
|
||||
mkdir -p $BACKUP_DIRECTORY
|
||||
fi
|
||||
BACKUP_SERVICES="$(docker ps --filter ancestor=postgres:14-alpine --format "{{.Names}}" | tr "\n" "\ ")"
|
||||
log INFO "Performing automatic maintenance: Creating Backups for $BACKUP_SERVICES";
|
||||
for service in $BACKUP_SERVICES; do
|
||||
if [ ! -d $BACKUP_DIRECTORY/$service ]; then
|
||||
message="Performing automatic maintenance: Creating Backup directory for $service in $BACKUP_DIRECTORY."
|
||||
hc_send log "$message"
|
||||
log INFO "$message"
|
||||
mkdir -p $BACKUP_DIRECTORY/$service
|
||||
fi
|
||||
if createEncryptedPostgresBackup "$BACKUP_DIRECTORY" "$service"; then
|
||||
message="Performing automatic maintenance: Stored encrypted Backup for $service in $BACKUP_DIRECTORY."
|
||||
hc_send log "$message"
|
||||
log INFO "$message"
|
||||
else
|
||||
fail_and_report 5 "Failed to create encrypted update for $service"
|
||||
fi
|
||||
done
|
||||
else
|
||||
log WARN "Automated backups are disabled (variable AUTO_BACKUPS != \"true\")"
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
# TODO: Print last commit explicit
|
||||
|
|
Loading…
Reference in New Issue