/database-backup-automator:automating-database-backupsfrom database-backup-automator
Generates production-ready backup scripts for PostgreSQL, MySQL, MongoDB, and SQLite with compression, GPG encryption, cron scheduling, and retention policies. Includes restore procedures.
Ships in database-backup-automator. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Generate production-ready backup scripts for PostgreSQL, MySQL, MongoDB, and SQLite with compression, encryption, scheduling, and retention policies.
#!/bin/bash
set -euo pipefail
BACKUP_DIR="/var/backups/postgresql"
DB_NAME="mydb"
DATE=$(date +%Y%m%d_%H%M%S)
BACKUP_FILE="${BACKUP_DIR}/${DB_NAME}_${DATE}.sql.gz"
pg_dump -h localhost -U postgres -d "$DB_NAME" \
--format=custom \
--compress=9 \
--file="$BACKUP_FILE"
# Encrypt with GPG (optional)
gpg --symmetric --cipher-algo AES256 --batch --passphrase-file /etc/backup.key "$BACKUP_FILE"
rm "$BACKUP_FILE"
#!/bin/bash
BACKUP_DIR="/var/backups/mysql"
DB_NAME="mydb"
DATE=$(date +%Y%m%d_%H%M%S)
mysqldump -h localhost -u root -p"${MYSQL_PASSWORD}" \
--single-transaction \
--routines \
--triggers \
"$DB_NAME" | gzip > "${BACKUP_DIR}/${DB_NAME}_${DATE}.sql.gz"
#!/bin/bash
mongodump --uri="mongodb://localhost:27017" \ # 27017: MongoDB port
--db=mydb \
--out=/var/backups/mongodb/$(date +%Y%m%d_%H%M%S) \
--gzip
Ask the user for:
Use scripts/backup_script_generator.py to create a customized backup script:
python3 ${CLAUDE_SKILL_DIR}/scripts/backup_script_generator.py \
--db-type postgresql \
--database mydb \
--output /opt/backup-scripts/mydb-backup.sh \
--compression gzip \
--encryption gpg
Use scripts/backup_scheduler.py to create cron entries:
python3 ${CLAUDE_SKILL_DIR}/scripts/backup_scheduler.py \
--script /opt/backup-scripts/mydb-backup.sh \
--schedule "0 2 * * *" \
--user postgres
After backup completes, validate integrity:
python3 ${CLAUDE_SKILL_DIR}/scripts/backup_validator.py \
--backup-file /var/backups/postgresql/mydb_20250115.sql.gz \
--db-type postgresql
Create matching restore script:
python3 ${CLAUDE_SKILL_DIR}/scripts/restore_script_generator.py \
--db-type postgresql \
--database mydb \
--output /opt/backup-scripts/mydb-restore.sh
| Schedule | Cron Expression | Description |
|---|---|---|
| Daily 2 AM | 0 2 * * * | Low-traffic window |
| Every 6 hours | 0 */6 * * * | Frequent backups |
| Weekly Sunday | 0 2 * * 0 | Weekly full backup |
| Monthly 1st | 0 2 1 * * | Monthly archive |
# Keep daily backups for 7 days
# Keep weekly backups for 4 weeks
# Keep monthly backups for 12 months
find /var/backups -name "*.gz" -mtime +7 -delete # Daily cleanup
find /var/backups/weekly -mtime +28 -delete # Weekly cleanup
find /var/backups/monthly -mtime +365 -delete # 365: Monthly cleanup
| Error | Cause | Solution |
|---|---|---|
| Connection refused | DB not running | Check service status: systemctl status postgresql |
| Permission denied | Wrong credentials | Verify user has backup privileges |
| Disk full | No space | Check space: df -h, clean old backups |
| Lock timeout | Active transactions | Use --single-transaction for MySQL |
references/postgresql_backup_restore.md - PostgreSQL backup guidereferences/mysql_backup_restore.md - MySQL backup guidereferences/mongodb_backup_restore.md - MongoDB backup guidereferences/sqlite_backup_restore.md - SQLite backup guidereferences/backup_best_practices.md - Security and storage best practicesreferences/cron_syntax.md - Cron scheduling referenceAutomate database backup processes with scheduling, compression, and encryption.
Basic usage: Apply automating database backups to a standard project setup with default configuration options.
Advanced scenario: Customize automating database backups for production environments with multiple constraints and team-specific requirements.
assets/README.md (opens in a new tab)config/settings.yaml (opens in a new tab)references/README.md (opens in a new tab)references/backup_best_practices.md (opens in a new tab)references/cron_syntax.md (opens in a new tab)references/mongodb_backup_restore.md (opens in a new tab)references/mysql_backup_restore.md (opens in a new tab)references/postgresql_backup_restore.md (opens in a new tab)references/sqlite_backup_restore.md (opens in a new tab)scripts/README.md (opens in a new tab)scripts/backup-monitoring.sh (opens in a new tab)scripts/backup_scheduler.py (opens in a new tab)scripts/backup_script_generator.py (opens in a new tab)scripts/backup_validator.py (opens in a new tab)scripts/restore_script_generator.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
PostgreSQL, MySQL, MongoDB, SQLite, Bash
database-backup, pg-dump, mysqldump, mongodump, cron-scheduling, gpg-encryption
npx claudepluginhub jeremylongshore/tons-of-skills-marketplace --plugin database-backup-automatorOther plugins' skills for the same job