ZoopaMario
d2b325a020
Some checks failed
Lint Bash Scripts / lint-bash (push) Failing after 23s
This commit refactors the codebase in order to make the shellcheck workflow pass.
36 lines
1.1 KiB
Bash
Executable file
36 lines
1.1 KiB
Bash
Executable file
#!/bin/bash
|
|
SCRIPT_ABS_LOCATION=$(realpath "$(dirname "${0}")")
|
|
|
|
source "$SCRIPT_ABS_LOCATION/portainer-backup.env"
|
|
source "$SCRIPT_ABS_LOCATION/../logger.sh"
|
|
|
|
# Container Names
|
|
APP_CONTAINER="portainer"
|
|
BACKUP_CONTAINER="duplicati"
|
|
|
|
SOURCE_DIR="/volumes/portainer"
|
|
|
|
# Stop portainer container
|
|
log "Stopping portainer container..."
|
|
docker stop "$APP_CONTAINER" || { log "Error: Failed to stop portainer."; exit 1; }
|
|
|
|
# Backup all files to target destination
|
|
log "Backing up portainer files (including the SQLite database)..."
|
|
docker exec "$BACKUP_CONTAINER" \
|
|
duplicati-cli backup \
|
|
"ssh://$BACKUP_DESTINATION" \
|
|
"$SOURCE_DIR" \
|
|
--backup-name="portainer backup" \
|
|
--keep-versions=7 \
|
|
--auth-username="$SFTP_USERNAME" \
|
|
--auth-password="$SFTP_PASSWORD" \
|
|
--passphrase="$BACKUP_ENCR_PASSPHRASE" \
|
|
--ssh-fingerprint="$SFTP_FINGERPRINT" \
|
|
--prefix="portainer" || { log "Error: Failed to backup portainer files and database."; exit 1; }
|
|
|
|
# Turn off Maintenance Mode
|
|
log "Starting portainer container..."
|
|
docker start "$APP_CONTAINER" || { log "Error: Failed to start portainer container."; exit 1; }
|
|
|
|
log "portainer backup completed successfully."
|