Initial commit
This commit is contained in:
15
.claude-plugin/plugin.json
Normal file
15
.claude-plugin/plugin.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "database-backup-automator",
|
||||
"description": "Automate database backups with scheduling, compression, encryption, and restore procedures",
|
||||
"version": "1.0.0",
|
||||
"author": {
|
||||
"name": "Claude Code Plugins",
|
||||
"email": "[email protected]"
|
||||
},
|
||||
"skills": [
|
||||
"./skills"
|
||||
],
|
||||
"commands": [
|
||||
"./commands"
|
||||
]
|
||||
}
|
||||
3
README.md
Normal file
3
README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# database-backup-automator
|
||||
|
||||
Automate database backups with scheduling, compression, encryption, and restore procedures
|
||||
120
commands/backup.md
Normal file
120
commands/backup.md
Normal file
@@ -0,0 +1,120 @@
|
||||
---
|
||||
description: Create automated database backup scripts and schedules
|
||||
---
|
||||
|
||||
# Database Backup Automator
|
||||
|
||||
You are a database backup specialist. Create comprehensive backup solutions with automation, monitoring, and recovery procedures.
|
||||
|
||||
## Backup Strategy Components
|
||||
|
||||
1. **Backup Types**
|
||||
- Full backups: Complete database dump
|
||||
- Incremental: Changes since last backup
|
||||
- Differential: Changes since last full backup
|
||||
- Point-in-time recovery: Transaction log backups
|
||||
|
||||
2. **Automation Setup**
|
||||
- Cron jobs for scheduled backups
|
||||
- Pre-backup validation checks
|
||||
- Post-backup verification
|
||||
- Retention policies
|
||||
- Rotation strategies
|
||||
|
||||
3. **Storage Options**
|
||||
- Local storage with rotation
|
||||
- Cloud storage (S3, GCS, Azure)
|
||||
- Network attached storage
|
||||
- Offsite replication
|
||||
|
||||
4. **Security Measures**
|
||||
- Encryption at rest
|
||||
- Encryption in transit
|
||||
- Access control
|
||||
- Audit logging
|
||||
|
||||
## Backup Script Template (PostgreSQL)
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
# PostgreSQL Backup Script
|
||||
|
||||
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"
|
||||
RETENTION_DAYS=7
|
||||
|
||||
# Create backup
|
||||
pg_dump $DB_NAME | gzip > $BACKUP_FILE
|
||||
|
||||
# Verify backup
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Backup successful: $BACKUP_FILE"
|
||||
|
||||
# Remove old backups
|
||||
find $BACKUP_DIR -name "${DB_NAME}_*.sql.gz" -mtime +$RETENTION_DAYS -delete
|
||||
|
||||
# Upload to S3 (optional)
|
||||
# aws s3 cp $BACKUP_FILE s3://my-backups/postgresql/
|
||||
else
|
||||
echo "Backup failed!"
|
||||
exit 1
|
||||
fi
|
||||
```
|
||||
|
||||
## Restore Procedure Template
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
# PostgreSQL Restore Script
|
||||
|
||||
BACKUP_FILE=$1
|
||||
|
||||
if [ -z "$BACKUP_FILE" ]; then
|
||||
echo "Usage: $0 <backup_file.sql.gz>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Restore database
|
||||
gunzip < $BACKUP_FILE | psql $DB_NAME
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Restore successful"
|
||||
else
|
||||
echo "Restore failed!"
|
||||
exit 1
|
||||
fi
|
||||
```
|
||||
|
||||
## Cron Schedule Examples
|
||||
|
||||
```cron
|
||||
# Daily backup at 2 AM
|
||||
0 2 * * * /path/to/backup.sh
|
||||
|
||||
# Hourly incremental backups
|
||||
0 * * * * /path/to/incremental_backup.sh
|
||||
|
||||
# Weekly full backup on Sunday at 3 AM
|
||||
0 3 * * 0 /path/to/full_backup.sh
|
||||
```
|
||||
|
||||
## Monitoring Checklist
|
||||
|
||||
- Backup completion status
|
||||
- Backup file size tracking
|
||||
- Storage space monitoring
|
||||
- Failed backup alerts
|
||||
- Restore testing schedule
|
||||
- Recovery time objectives (RTO)
|
||||
- Recovery point objectives (RPO)
|
||||
|
||||
## When Invoked
|
||||
|
||||
1. Identify database system (PostgreSQL, MySQL, MongoDB, etc.)
|
||||
2. Determine backup frequency and retention
|
||||
3. Generate backup scripts
|
||||
4. Create restore procedures
|
||||
5. Set up monitoring and alerts
|
||||
6. Provide testing instructions
|
||||
61
plugin.lock.json
Normal file
61
plugin.lock.json
Normal file
@@ -0,0 +1,61 @@
|
||||
{
|
||||
"$schema": "internal://schemas/plugin.lock.v1.json",
|
||||
"pluginId": "gh:jeremylongshore/claude-code-plugins-plus:plugins/database/database-backup-automator",
|
||||
"normalized": {
|
||||
"repo": null,
|
||||
"ref": "refs/tags/v20251128.0",
|
||||
"commit": "da95e65c7cc114f3b563a2007bc59ef87e293588",
|
||||
"treeHash": "aefd50dce42576aa71b1a3debf3e0f416871e4029feab8ce26efbf0e04cf2b8f",
|
||||
"generatedAt": "2025-11-28T10:18:18.670428Z",
|
||||
"toolVersion": "publish_plugins.py@0.2.0"
|
||||
},
|
||||
"origin": {
|
||||
"remote": "git@github.com:zhongweili/42plugin-data.git",
|
||||
"branch": "master",
|
||||
"commit": "aa1497ed0949fd50e99e70d6324a29c5b34f9390",
|
||||
"repoRoot": "/Users/zhongweili/projects/openmind/42plugin-data"
|
||||
},
|
||||
"manifest": {
|
||||
"name": "database-backup-automator",
|
||||
"description": "Automate database backups with scheduling, compression, encryption, and restore procedures",
|
||||
"version": "1.0.0"
|
||||
},
|
||||
"content": {
|
||||
"files": [
|
||||
{
|
||||
"path": "README.md",
|
||||
"sha256": "c5fdfcaaac59e456204472fcce0bf72512703361ff1f32c6361cce12c469c684"
|
||||
},
|
||||
{
|
||||
"path": ".claude-plugin/plugin.json",
|
||||
"sha256": "7b4ae20ba366a3c4049692d3c3ff4c2deff8624d87d03648e7ffe5b3b274a3ba"
|
||||
},
|
||||
{
|
||||
"path": "commands/backup.md",
|
||||
"sha256": "6d30d6c8c08c6df391bca4f6b77c6bf944b6eda80accb6c0826b7075ee753db3"
|
||||
},
|
||||
{
|
||||
"path": "skills/database-backup-automator/SKILL.md",
|
||||
"sha256": "ab63d7ea093d1c2ae4074dc0810b11d905de1a9b90ced85cb44a1dffc9abf5db"
|
||||
},
|
||||
{
|
||||
"path": "skills/database-backup-automator/references/README.md",
|
||||
"sha256": "5edb7f3867d414d31b2dc36a1f73887a5eef2e030a29e9ba13776638e43890fb"
|
||||
},
|
||||
{
|
||||
"path": "skills/database-backup-automator/scripts/README.md",
|
||||
"sha256": "9d686acba9e332b5ff6204ee8ff2238d9e861ba485195ed0dfe60e9314acf0f3"
|
||||
},
|
||||
{
|
||||
"path": "skills/database-backup-automator/assets/README.md",
|
||||
"sha256": "7886ad741ee5dd09057b8033954b61d265f8cf85b052c537e80e1cb9ac8bc13c"
|
||||
}
|
||||
],
|
||||
"dirSha256": "aefd50dce42576aa71b1a3debf3e0f416871e4029feab8ce26efbf0e04cf2b8f"
|
||||
},
|
||||
"security": {
|
||||
"scannedAt": null,
|
||||
"scannerVersion": null,
|
||||
"flags": []
|
||||
}
|
||||
}
|
||||
54
skills/database-backup-automator/SKILL.md
Normal file
54
skills/database-backup-automator/SKILL.md
Normal file
@@ -0,0 +1,54 @@
|
||||
---
|
||||
name: automating-database-backups
|
||||
description: |
|
||||
This skill automates database backups using the database-backup-automator plugin. It creates scripts for scheduled backups, compression, encryption, and restore procedures across PostgreSQL, MySQL, MongoDB, and SQLite. Use this when the user requests database backup automation, disaster recovery planning, setting up backup schedules, or creating restore procedures. The skill is triggered by phrases like "create database backup", "automate database backups", "setup backup schedule", or "generate restore procedure".
|
||||
allowed-tools: Read, Write, Edit, Grep, Glob, Bash
|
||||
version: 1.0.0
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
This skill streamlines the creation of database backup solutions. It generates scripts, configures schedules, and provides comprehensive restore procedures, ensuring data safety and efficient recovery.
|
||||
|
||||
## How It Works
|
||||
|
||||
1. **Analyze Requirements**: Determines the database type (PostgreSQL, MySQL, MongoDB, or SQLite) and backup requirements (frequency, retention).
|
||||
2. **Generate Scripts**: Creates backup scripts with compression and encryption.
|
||||
3. **Schedule Backups**: Sets up cron jobs for automated, scheduled backups.
|
||||
4. **Document Restore**: Generates clear, concise restore procedures.
|
||||
|
||||
## When to Use This Skill
|
||||
|
||||
This skill activates when you need to:
|
||||
- Create a backup schedule for a database.
|
||||
- Automate the database backup process.
|
||||
- Generate scripts for database restoration.
|
||||
- Implement a disaster recovery plan for a database.
|
||||
|
||||
## Examples
|
||||
|
||||
### Example 1: Setting up Daily Backups for PostgreSQL
|
||||
|
||||
User request: "Create daily backups for my PostgreSQL database."
|
||||
|
||||
The skill will:
|
||||
1. Generate a `pg_dump` script with compression and encryption.
|
||||
2. Create a cron job to run the backup script daily.
|
||||
|
||||
### Example 2: Automating Weekly Backups for MongoDB
|
||||
|
||||
User request: "Automate weekly backups for my MongoDB database."
|
||||
|
||||
The skill will:
|
||||
1. Generate a `mongodump` script with compression and encryption.
|
||||
2. Create a cron job to run the backup script weekly and implement a retention policy.
|
||||
|
||||
## Best Practices
|
||||
|
||||
- **Retention Policies**: Implement clear retention policies to manage storage space.
|
||||
- **Testing Restores**: Regularly test restore procedures to ensure data integrity.
|
||||
- **Secure Storage**: Store backups in secure, encrypted locations, preferably offsite.
|
||||
|
||||
## Integration
|
||||
|
||||
This skill can integrate with cloud storage plugins (S3, GCS, Azure) for offsite backup storage and monitoring plugins for backup success/failure alerts.
|
||||
7
skills/database-backup-automator/assets/README.md
Normal file
7
skills/database-backup-automator/assets/README.md
Normal file
@@ -0,0 +1,7 @@
|
||||
# Assets
|
||||
|
||||
Bundled resources for database-backup-automator skill
|
||||
|
||||
- [ ] backup_template.sh: A template shell script for performing backups.
|
||||
- [ ] restore_template.sh: A template shell script for performing restores.
|
||||
- [ ] example_backup_config.json: Example configuration file for defining backup schedules and parameters.
|
||||
10
skills/database-backup-automator/references/README.md
Normal file
10
skills/database-backup-automator/references/README.md
Normal file
@@ -0,0 +1,10 @@
|
||||
# References
|
||||
|
||||
Bundled resources for database-backup-automator skill
|
||||
|
||||
- [ ] postgresql_backup_restore.md: Detailed guide on PostgreSQL backup and restore procedures.
|
||||
- [ ] mysql_backup_restore.md: Detailed guide on MySQL backup and restore procedures.
|
||||
- [ ] mongodb_backup_restore.md: Detailed guide on MongoDB backup and restore procedures.
|
||||
- [ ] sqlite_backup_restore.md: Detailed guide on SQLite backup and restore procedures.
|
||||
- [ ] backup_best_practices.md: General best practices for database backups, including security and storage considerations.
|
||||
- [ ] cron_syntax.md: A quick reference guide to cron syntax for scheduling backups.
|
||||
8
skills/database-backup-automator/scripts/README.md
Normal file
8
skills/database-backup-automator/scripts/README.md
Normal file
@@ -0,0 +1,8 @@
|
||||
# Scripts
|
||||
|
||||
Bundled resources for database-backup-automator skill
|
||||
|
||||
- [ ] backup_script_generator.py: Generates backup scripts based on database type and user-defined parameters.
|
||||
- [ ] restore_script_generator.py: Generates restore scripts based on backup location and database type.
|
||||
- [ ] backup_scheduler.py: Creates and manages cron jobs for automated backups.
|
||||
- [ ] backup_validator.py: Validates the integrity of the backup files.
|
||||
Reference in New Issue
Block a user