Improve backup scripts with logging and remove duplicate rotation

db-backup-standalone.sh:
- Add logging with timestamps to backups/db-backup-standalone.log
- Add SCRIPT_DIR to make all paths relative to script location
- Add detailed logging for each backup step (stop, backup, rotate, start)
- Log rotation status and which old backups are removed

db-scheduled-backup.sh:
- Remove duplicate backup rotation logic (now handled in standalone script)
- Comment out cleanup code to avoid redundant operations

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-26 09:42:20 +01:00
parent f98a2a5908
commit dc5698d7d6
2 changed files with 38 additions and 13 deletions

View File

@@ -33,14 +33,15 @@ fi
log "Starting database backup..."
"$BACKUP_SCRIPT"
# Delete backups older than 7 days
BACKUP_DIR="${BACKUP_DIR:-backups}"
if [ -d "$BACKUP_DIR" ]; then
log "Cleaning up backups older than 7 days in $BACKUP_DIR..."
find "$BACKUP_DIR" -name "mongo-volume-backup-*.tar.gz" -type f -mtime +7 -delete
log "Cleanup completed."
else
log "Warning: Backup directory $BACKUP_DIR not found, skipping cleanup."
fi
# Rotation is already handled in db-backup-standalone.sh, so no need to repeat it here.
# # Delete backups older than 7 days
# BACKUP_DIR="${BACKUP_DIR:-backups}"
# if [ -d "$BACKUP_DIR" ]; then
# log "Cleaning up backups older than 7 days in $BACKUP_DIR..."
# find "$BACKUP_DIR" -name "mongo-volume-backup-*.tar.gz" -type f -mtime +7 -delete
# log "Cleanup completed."
# else
# log "Warning: Backup directory $BACKUP_DIR not found, skipping cleanup."
# fi
log "Scheduled backup completed successfully."