2024-08-04 23:10:36 +02:00
|
|
|
#!/bin/bash
|
|
|
|
SCRIPT_ABS_LOCATION=$(realpath "$(dirname "${0}")")
|
|
|
|
|
2024-12-29 15:08:09 +01:00
|
|
|
# shellcheck disable=SC1090
|
2024-12-30 01:49:10 +01:00
|
|
|
source "$SCRIPT_ABS_LOCATION/../common-backup.sh"
|
2024-12-29 15:08:09 +01:00
|
|
|
# shellcheck disable=SC1090
|
2024-12-30 01:49:10 +01:00
|
|
|
source "$SCRIPT_ABS_LOCATION/duplicati-backup.env"
|
2024-08-04 23:10:36 +02:00
|
|
|
|
2024-12-29 15:08:09 +01:00
|
|
|
# shellcheck disable=SC2034
|
2024-08-04 23:10:36 +02:00
|
|
|
LOG_FILE="$SCRIPT_ABS_LOCATION/duplicati-backup.log"
|
|
|
|
|
2024-12-29 15:08:09 +01:00
|
|
|
TMP_FILEPATH="$SCRIPT_ABS_LOCATION"
|
|
|
|
if [ -z "$TMP_FILEPATH" ]; then
|
2024-12-30 01:49:10 +01:00
|
|
|
log "Error: TMP_FILEPATH is not set."
|
|
|
|
exit 1
|
2024-12-29 15:08:09 +01:00
|
|
|
fi
|
2024-08-04 23:10:36 +02:00
|
|
|
|
2024-12-30 01:49:10 +01:00
|
|
|
stop_container duplicati
|
2024-08-04 23:10:36 +02:00
|
|
|
|
2024-12-30 01:49:10 +01:00
|
|
|
tar_and_encrypt "$SOURCE_DIR" "$TMP_FILEPATH/$TMP_FILENAME" "$BACKUP_ENCR_PASSPHRASE"
|
2024-08-04 23:10:36 +02:00
|
|
|
|
2024-12-30 01:49:10 +01:00
|
|
|
remove_old_backups \
|
|
|
|
"$SSH_USERNAME" \
|
|
|
|
"$SSH_DESTINATION" \
|
|
|
|
"$SSH_KEY" \
|
|
|
|
"$SSH_PORT" \
|
|
|
|
"$BACKUP_FOLDER" \
|
|
|
|
"$MAX_BACKUPS"
|
2024-08-04 23:10:36 +02:00
|
|
|
|
2024-12-30 01:49:10 +01:00
|
|
|
scp_transfer \
|
|
|
|
"$TMP_FILEPATH/$TMP_FILENAME" \
|
|
|
|
"$SSH_USERNAME" \
|
|
|
|
"$SSH_DESTINATION" \
|
|
|
|
"$SSH_KEY" \
|
|
|
|
"$SSH_PORT" \
|
|
|
|
"${BACKUP_FOLDER}${TMP_FILENAME}"
|
2024-08-04 23:10:36 +02:00
|
|
|
|
2024-12-30 01:49:10 +01:00
|
|
|
log "Cleaning up temporary archive..."
|
|
|
|
rm "$TMP_FILEPATH/$TMP_FILENAME" || {
|
|
|
|
log "Error: Failed to remove the temporary file."
|
|
|
|
exit 1
|
|
|
|
}
|
2024-08-04 23:10:36 +02:00
|
|
|
|
2024-12-30 01:49:10 +01:00
|
|
|
start_container duplicati
|
2024-08-04 23:10:36 +02:00
|
|
|
|
2024-12-30 01:49:10 +01:00
|
|
|
log "duplicati backup completed."
|