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.
43 lines
1.4 KiB
Bash
Executable file
43 lines
1.4 KiB
Bash
Executable file
#!/bin/bash
|
|
SCRIPT_ABS_LOCATION=$(realpath "$(dirname "${0}")")
|
|
|
|
source "$SCRIPT_ABS_LOCATION/cryptpad-backup.env"
|
|
source "$SCRIPT_ABS_LOCATION/../logger.sh"
|
|
|
|
# Container Names
|
|
CONTAINER="cryptpad"
|
|
BACKUP_CONTAINER="duplicati"
|
|
|
|
SOURCE_DIR="/mnt/data/cryptpad"
|
|
|
|
# Cleanup inactive and archive files
|
|
log "Cleaning up inactive accounts and files to save space..."
|
|
docker exec cryptpad \
|
|
/usr/local/bin/node scripts/evict-inactive.js \
|
|
--workdir=/cryptpad || { log "Error: Failed to clean up inactive files"; exit 1; }
|
|
|
|
log "Cleaning up archived beyond retention period files to save space..."
|
|
docker exec cryptpad \
|
|
/usr/local/bin/node scripts/evict-archived.js \
|
|
--workdir=/cryptpad || { log "Error: Failed to clean up inactive files"; exit 1; }
|
|
|
|
# Backup all files to target destination
|
|
log "Backing up cryptpad files and database..."
|
|
docker exec "$BACKUP_CONTAINER" \
|
|
duplicati-cli backup "ssh://$BACKUP_DESTINATION" \
|
|
"$SOURCE_DIR/data" \
|
|
"$SOURCE_DIR/datastore" \
|
|
"$SOURCE_DIR/block" \
|
|
"$SOURCE_DIR/blob" \
|
|
"$SOURCE_DIR/config/config.js" \
|
|
"$SOURCE_DIR/customize" \
|
|
"$SOURCE_DIR/customize.dist" \
|
|
--backup-name="$CONTAINER backup" \
|
|
--keep-versions=7 \
|
|
--auth-username="$SFTP_USERNAME" \
|
|
--auth-password="$SFTP_PASSWORD" \
|
|
--passphrase="$BACKUP_ENCR_PASSPHRASE" \
|
|
--ssh-fingerprint="$SFTP_FINGERPRINT" \
|
|
--prefix="cryptpad" || { log "Error: Failed to backup cryptpad files and database."; exit 1; }
|
|
log "cryptpad backup completed successfully."
|