backup-automation/vaultwarden/vaultwarden-backup.sh

35 lines
880 B
Bash
Raw Normal View History

2024-08-04 23:10:36 +02:00
#!/bin/bash
SCRIPT_ABS_LOCATION=$(realpath "$(dirname "${0}")")
# shellcheck disable=SC1090
source "$SCRIPT_ABS_LOCATION/vaultwarden-backup.env"; \
source "$SCRIPT_ABS_LOCATION/../logger.sh"; \
source "$SCRIPT_ABS_LOCATION/../common-backup.sh"
2024-08-04 23:10:36 +02:00
# shellcheck disable=SC2034
2024-08-04 23:10:36 +02:00
LOG_FILE="$SCRIPT_ABS_LOCATION/vaultwarden-backup.log"
BACKUP_CONTAINER="duplicati"
SOURCE_DIR="/mnt/data/vaultwarden"
DB_TMP_BAK_NAME="vaultwarden-db_$(date +"%Y%m%d").sqlite3"
dump_sqlite_db "$SOURCE_DIR/db.sqlite3" "$SOURCE_DIR/$DB_TMP_BAK_NAME"
run_duplicati_backup \
"$BACKUP_CONTAINER" \
"$BACKUP_DESTINATION" \
"vaultwarden" \
7 \
"$SFTP_USERNAME" \
"$SFTP_PASSWORD" \
"$BACKUP_ENCR_PASSPHRASE" \
"$SFTP_FINGERPRINT" \
"$SOURCE_DIR"
log "Deleting vaultwarden temp DB backup..."
rm "$SOURCE_DIR/$DB_TMP_BAK_NAME" || {
log "Error: Failed to delete temp DB backup."
exit 1
}