home / skills / openclaw / skills / backup-gen

backup-gen skill

/skills/lxgicstudios/backup-gen

This skill generates complete database backup scripts for various databases to cloud or local storage with automated retention.

npx playbooks add skill openclaw/skills --skill backup-gen

Review the files below or copy the command above to add this skill to your agents.

Files (8)
SKILL.md
2.3 KB
---
name: backup-script-gen
description: Generate database backup scripts with AI. Use when you need automated backups to S3, GCS, or local storage.
---

# Backup Script Generator

Setting up database backups involves shell scripts, cron jobs, cloud CLI tools, and retention policies. This tool generates complete backup scripts for any database to any destination.

**One command. Zero config. Just works.**

## Quick Start

```bash
npx ai-backup-script "PostgreSQL daily to S3"
```

## What It Does

- Generates complete backup scripts with error handling
- Supports all major databases (Postgres, MySQL, MongoDB, Redis)
- Handles cloud destinations (S3, GCS, Azure Blob)
- Includes retention and rotation logic

## Usage Examples

```bash
# PostgreSQL to S3
npx ai-backup-script "PostgreSQL daily to S3 with 30 day retention"

# MongoDB to Google Cloud Storage
npx ai-backup-script "MongoDB hourly to GCS"

# MySQL to local with rotation
npx ai-backup-script "MySQL weekly to /backups with 4 week rotation"

# Redis with compression
npx ai-backup-script "Redis snapshot to S3 compressed"
```

## Best Practices

- **Test your restores** - a backup you can't restore is useless
- **Monitor failures** - add alerting to your backup jobs
- **Encrypt at rest** - especially for cloud storage
- **Document the restore process** - future you will thank present you

## When to Use This

- Setting up backups for a new database
- Migrating from manual backups to automated
- Need a quick backup script for a side project
- Want a starting point to customize

## Part of the LXGIC Dev Toolkit

This is one of 110+ free developer tools built by LXGIC Studios. No paywalls, no sign-ups, no API keys on free tiers. Just tools that work.

**Find more:**
- GitHub: https://github.com/LXGIC-Studios
- Twitter: https://x.com/lxgicstudios
- Substack: https://lxgicstudios.substack.com
- Website: https://lxgic.dev

## Requirements

No install needed. Just run with npx. Node.js 18+ recommended. Needs OPENAI_API_KEY environment variable.

```bash
npx ai-backup-script --help
```

## How It Works

Takes your description of database type, schedule, and destination. Generates a shell script using the appropriate dump tool (pg_dump, mysqldump, mongodump, etc.) with proper flags, compression, upload commands, and cleanup logic.

## License

MIT. Free forever. Use it however you want.

Overview

This skill generates ready-to-run database backup scripts using AI. It produces shell scripts that include dumping, compression, upload to S3/GCS/Azure or saving locally, plus rotation and retention logic. Use it to quickly bootstrap reliable, repeatable backups without handcrafting commands.

How this skill works

You provide a short description of the database type, schedule, and destination. The tool selects the correct dump utility (pg_dump, mysqldump, mongodump, redis-cli/snapshot), builds a shell script with error handling, optional compression, cloud CLI upload steps, and retention/rotation cleanup. Scripts include exit codes and basic logging so they can be scheduled in cron or other job runners.

When to use it

  • Setting up backups for a new database quickly
  • Automating backups for side projects or prototypes
  • Migrating from manual backup steps to scripted automation
  • Creating cloud backups to S3, GCS, or Azure without writing CLI calls by hand
  • Generating a starting script to customize for enterprise policies

Best practices

  • Test restores regularly—verify backups are restorable before relying on them
  • Add monitoring and alerting for job failures and retention errors
  • Encrypt backups at rest and in transit for sensitive data
  • Store backup scripts and credentials securely; avoid committing secrets to source control
  • Validate cloud CLI credentials and lifecycle/retention rules after deployment

Example use cases

  • PostgreSQL daily dump to S3 with 30-day retention and optional gzip compression
  • MongoDB hourly dumps uploaded to Google Cloud Storage with timestamped filenames
  • MySQL weekly local backups with rotation keeping the last 4 weeks
  • Redis RDB snapshot to S3 with post-upload integrity check and cleanup
  • Generate a compressed SQLite copy for a static site and push to a private bucket

FAQ

Do I need anything installed to run the generated script?

Yes—the target database client (pg_dump, mysqldump, mongodump, redis-cli) and the cloud CLI (aws, gcloud, az) for cloud uploads must be available on the machine running the script.

Can I customize retention and encryption options?

Yes. The generated script includes retention parameters and hooks for encryption; you can modify flags or insert your preferred encryption tool before upload.