ZoopaMario
6f394a867a
This commit refactors the codebase in order to make the shellcheck workflow pass.
41 lines
1.4 KiB
Bash
Executable file
41 lines
1.4 KiB
Bash
Executable file
#!/bin/bash
|
|
SCRIPT_ABS_LOCATION=$(realpath "$(dirname "${0}")")
|
|
|
|
# shellcheck disable=SC1090
|
|
source "$SCRIPT_ABS_LOCATION/vaultwarden-backup.env"
|
|
|
|
# shellcheck disable=SC1090
|
|
source "$SCRIPT_ABS_LOCATION/../logger.sh"
|
|
|
|
# Container Names
|
|
BACKUP_CONTAINER="duplicati"
|
|
|
|
# shellcheck disable=SC2034
|
|
LOG_FILE="$SCRIPT_ABS_LOCATION/vaultwarden-backup.log"
|
|
|
|
SOURCE_DIR="/mnt/data/vaultwarden"
|
|
|
|
# Dump Database
|
|
log "Dumping vaultwarden database..."
|
|
DB_TMP_BAK_NAME=vaultwarden-db_$(date +"%Y%m%d").sqlite3
|
|
sqlite3 "$SOURCE_DIR/db.sqlite3" ".backup $SOURCE_DIR/$DB_TMP_BAK_NAME" || { log "Error: Failed to dump the Nextcloud database."; exit 1; }
|
|
|
|
# Backup all files to target destination
|
|
log "Backing up vaultwarden files and database..."
|
|
docker exec "$BACKUP_CONTAINER" duplicati-cli backup \
|
|
"ssh://$BACKUP_DESTINATION" \
|
|
"$SOURCE_DIR" \
|
|
--backup-name="vaultwarden backup" \
|
|
--keep-versions=7 \
|
|
--auth-username="$SFTP_USERNAME" \
|
|
--auth-password="$SFTP_PASSWORD" \
|
|
--passphrase="$BACKUP_ENCR_PASSPHRASE" \
|
|
--ssh-fingerprint="$SFTP_FINGERPRINT" \
|
|
--prefix="vaultwarden" || { log "Error: Failed to backup vaultwarden files and database."; exit 1; }
|
|
|
|
# Delete temporary backup files
|
|
log "Deleting temporary backup files..."
|
|
rm "$SOURCE_DIR/$DB_TMP_BAK_NAME" || { log "Error: Failed to delete temporary backup files."; exit 1; }
|
|
|
|
log "vaultwarden backup completed successfully."
|