diff --git a/backups/create_vaultwarden_backup.sh b/backups/create_vaultwarden_backup.sh index 5128303..8befb8f 100755 --- a/backups/create_vaultwarden_backup.sh +++ b/backups/create_vaultwarden_backup.sh @@ -23,23 +23,14 @@ docker exec --env-file "${PASSFILE}" "${database_container}" pg_dump 'vaultwarde docker cp "${database_container}":"${internal_database_backupfile}" "${BACKUP_DEST}" # Files backup -files=('attachments' 'sends' 'config.json' 'rsa_key.pem' 'rsa_key.pub.pem') -for file in "${files[@]}"; do - >&2 echo "Copying ${file}" +for file in 'attachments' 'sends' 'config.json' 'rsa_key.pem' 'rsa_key.pub.pem'; do + >&2 printf 'Copying %s\n' "${file}" docker cp -a "${base_container}":"/data/${file}" "${BACKUP_DEST}" done # Backup cleanup -# Only keep the 30 most recent backups => probably a month worth of backups, seems about right. +# Only keep 30 days of backups, seems about right. >&2 echo 'Cleaning up old database backups' -pushd "${BACKUP_DEST}" -excess="$( ls -1 | grep sqlbkp | head -n -30 )" -if [ -n "${excess}" ]; then - >&2 echo "Removing ${excess}" - rm "${excess}" -else - >&2 echo 'Skipping: nothing to remove' -fi -popd +find "${BACKUP_DEST}" -name '*sqlbkp*' -type f -mtime +30 -print # -delete >&2 echo 'Done'