
backup-recovery
Implement backup and recovery strategies. Configure rsync, Restic, and cloud backups. Use when designing data protection solutions.
- Installs
- 409
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/bagelhole/devops-security-agent-skills --skill backup-recovery- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads backup-recovery automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Backup and Recovery
Implement comprehensive backup and recovery strategies using rsync, Restic, and cloud storage backends. Covers the 3-2-1 rule, automated scheduling, S3/B2 backends, encryption, restore procedures, and verification testing.
When to Use
- Designing a backup strategy for servers, databases, or application data
- Setting up Restic for encrypted, deduplicated backups to local or cloud storage
- Automating backups with systemd timers or cron
- Restoring data after accidental deletion, corruption, or disaster
- Migrating data between environments using backup/restore workflows
- Verifying backup integrity and testing recovery procedures
Prerequisites
rsyncinstalled (included in most Linux distributions)resticinstalled (v0.16+ recommended)- Cloud CLI configured for the backend: AWS CLI for S3,
b2CLI for Backblaze B2 - Sufficient storage at the backup destination (2-3x source size for retention)
- SSH access for remote rsync targets
systemdorcronfor scheduling
The 3-2-1 Backup Rule
- 3 copies of your data (1 primary + 2 backups)
- 2 different storage media or types (e.g., local disk + cloud)
- 1 copy offsite (cloud storage, remote datacenter)
rsync Backups
Basic Operations
# Sync a local directory to a backup location
rsync -avz --delete /data/ /backup/data/
# Flags explained:
# -a archive mode (preserves permissions, ownership, timestamps, symlinks)
# -v verbose output
# -z compress data during transfer
# --delete remove files at destination that no longer exist at source
# Sync to a remote server over SSH
rsync -avz -e "ssh -i ~/.ssh/backup_key" /data/ backup@remote:/backups/server01/
# Exclude patterns
rsync -avz --delete \
--exclude='*.tmp' \
--exclude='*.log' \
--exclude='.cache/' \
--exclude='node_modules/' \
/data/ /backup/data/
# Use an exclude file for complex patterns
rsync -avz --delete --exclude-from=/etc/backup-excludes.txt /data/ /backup/data/
# Dry run (preview what would change)
rsync -avzn --delete /data/ /backup/data/
# Limit bandwidth to 50 MB/s and show progress
rsync -avz --bwlimit=50000 --progress /data/ backup@remote:/backups/
Incremental Backups with Hard Links
# Incremental: unchanged files hard-linked to previous backup (saves space)
rsync -avz --delete \
--link-dest=/backup/daily/latest \
/data/ /backup/daily/$(date +%Y-%m-%d)/
# Update the 'latest' symlink
ln -snf /backup/daily/$(date +%Y-%m-%d) /backup/daily/latest
# Remove backups older than 30 days
find /backup/daily -maxdepth 1 -type d -name "20*" -mtime +30 -exec rm -rf {} \;
Restic Backup
Installation
# Debian / Ubuntu
apt install -y restic
# RHEL / CentOS
dnf install -y restic
# Or download the latest binary
curl -L https://github.com/restic/restic/releases/latest/download/restic_0.17.3_linux_amd64.bz2 \
| bunzip2 > /usr/local/bin/restic
chmod +x /usr/local/bin/restic
# Verify installation
restic version
Initialize a Repository
# Local repository
restic init --repo /backup/restic-repo
# AWS S3 backend
export AWS_ACCESS_KEY_ID="AKIAEXAMPLE"
export AWS_SECRET_ACCESS_KEY="secretkey"
restic init --repo s3:s3.amazonaws.com/my-backup-bucket
# S3-compatible (MinIO)
export AWS_ACCESS_KEY_ID="minioadmin"
export AWS_SECRET_ACCESS_KEY="miniosecret"
restic init --repo s3:http://minio.example.com:9000/backup-bucket
# Backblaze B2 backend
export B2_ACCOUNT_ID="accountid"
export B2_ACCOUNT_KEY="accountkey"
restic init --repo b2:my-backup-bucket:server01
# SFTP backend
restic init --repo sftp:backup@remote:/backups/server01
# Restic will prompt for a repository password -- store it securely
# Use a password file for automation
echo "my-secure-repo-password" > /etc/restic/password.txt
chmod 600 /etc/restic/password.txt
Backup Operations
# Basic backup
restic backup /data --repo /backup/restic-repo --password-file /etc/restic/password.txt
# Backup multiple directories
restic backup /data /etc /var/lib/postgresql \
--repo s3:s3.amazonaws.com/my-backup-bucket \
--password-file /etc/restic/password.txt
# Backup with exclusions
restic backup /data \
--exclude='*.tmp' \
--exclude='*.log' \
--exclude-file=/etc/restic/excludes.txt \
--repo /backup/restic-repo \
--password-file /etc/restic/password.txt
# Backup with tags (useful for filtering snapshots later)
restic backup /data \
--tag server01 --tag production --tag daily \
--repo /backup/restic-repo \
--password-file /etc/restic/password.txt
# Backup stdin (e.g., database dump)
pg_dump -U postgres mydb | restic backup --stdin --stdin-filename mydb.sql \
--repo s3:s3.amazonaws.com/my-backup-bucket \
--password-file /etc/restic/password.txt
# Verbose output showing files processed
restic backup /data -v \
--repo /backup/restic-repo \
--password-file /etc/restic/password.txt
Snapshot Management
# List all snapshots (add --tag <tag> to filter)
restic snapshots --repo /backup/restic-repo --password-file /etc/restic/password.txt
# Browse files in the latest snapshot
restic ls latest --repo /backup/restic-repo --password-file /etc/restic/password.txt
# Compare two snapshots
restic diff abc123 def456 --repo /backup/restic-repo --password-file /etc/restic/password.txt
Retention Policy (forget + prune)
# Apply retention policy and reclaim space
restic forget \
--keep-daily 7 --keep-weekly 4 --keep-monthly 12 --keep-yearly 3 \
--prune \
--repo /backup/restic-repo \
--password-file /etc/restic/password.txt
# Dry run to preview what would be removed
restic forget --keep-daily 7 --keep-weekly 4 --keep-monthly 12 \
--dry-run --repo /backup/restic-repo --password-file /etc/restic/password.txt
Restore Procedures
# Restore the latest snapshot to a target directory
restic restore latest --target /restore \
--repo /backup/restic-repo \
--password-file /etc/restic/password.txt
# Restore a specific snapshot by ID
restic restore abc123 --target /restore \
--repo /backup/restic-repo \
--password-file /etc/restic/password.txt
# Restore only specific files or directories
restic restore latest --target /restore --include "/data/config" \
--repo /backup/restic-repo \
--password-file /etc/restic/password.txt
# Mount a snapshot as a FUSE filesystem (browse and copy individual files)
mkdir -p /mnt/restic
restic mount /mnt/restic --repo /backup/restic-repo --password-file /etc/restic/password.txt &
# Browse: ls /mnt/restic/snapshots/latest/
# Unmount when done: umount /mnt/restic
Verification
# Verify repository integrity (checks all data and metadata)
restic check --repo /backup/restic-repo --password-file /etc/restic/password.txt
# Full data verification (reads all pack files -- slow but thorough)
restic check --read-data --repo /backup/restic-repo --password-file /etc/restic/password.txt
# Verify a random subset of data (faster than full read)
restic check --read-data-subset=5% --repo /backup/restic-repo --password-file /etc/restic/password.txt
Automated Backup with Environment File
/etc/restic/env
# Repository configuration
export RESTIC_REPOSITORY="s3:s3.amazonaws.com/my-backup-bucket"
export RESTIC_PASSWORD_FILE="/etc/restic/password.txt"
export AWS_ACCESS_KEY_ID="AKIAEXAMPLE"
export AWS_SECRET_ACCESS_KEY="secretkey"
# Optional: set cache directory
export RESTIC_CACHE_DIR="/var/cache/restic"
Backup Script
#!/bin/bash
# /usr/local/bin/restic-backup.sh
set -euo pipefail
source /etc/restic/env
LOG="/var/log/restic-backup.log"
echo "$(date): Starting backup" >> "$LOG"
restic backup /data /etc /var/lib/postgresql \
--exclude-file=/etc/restic/excludes.txt \
--tag "$(hostname)" --tag daily \
--verbose >> "$LOG" 2>&1
restic forget --keep-daily 7 --keep-weekly 4 --keep-monthly 12 \
--prune >> "$LOG" 2>&1
# Weekly integrity check (Sundays)
[ "$(date +%u)" -eq 7 ] && restic check --read-data-subset=10% >> "$LOG" 2>&1
echo "$(date): Backup completed" >> "$LOG"
chmod +x /usr/local/bin/restic-backup.sh
Scheduled Backups
Systemd Timer (Recommended)
# /etc/systemd/system/restic-backup.service
[Unit]
Description=Restic backup
After=network-online.target
Wants=network-online.target
[Service]
Type=oneshot
User=root
ExecStart=/usr/local/bin/restic-backup.sh
Nice=10
IOSchedulingClass=idle
# /etc/systemd/system/restic-backup.timer
[Unit]
Description=Run Restic backup daily at 2 AM
[Timer]
OnCalendar=*-*-* 02:00:00
Persistent=true
RandomizedDelaySec=900
[Install]
WantedBy=timers.target
# Enable and start the timer
systemctl daemon-reload
systemctl enable --now restic-backup.timer
# Check timer status
systemctl list-timers restic-backup.timer
# Run manually for testing
systemctl start restic-backup.service
journalctl -u restic-backup.service -f
Database Backups with Restic
# PostgreSQL: stream dump directly into restic (no temp file)
pg_dump -U postgres -Fc mydb | restic backup --stdin --stdin-filename mydb.dump \
--tag postgres --tag mydb \
--repo s3:s3.amazonaws.com/my-backup-bucket \
--password-file /etc/restic/password.txt
# MySQL / MariaDB: stream dump into restic
mysqldump --all-databases --single-transaction | \
restic backup --stdin --stdin-filename all-databases.sql \
--tag mysql \
--repo s3:s3.amazonaws.com/my-backup-bucket \
--password-file /etc/restic/password.txt
# Restore PostgreSQL from restic
restic dump latest mydb.dump \
--repo s3:s3.amazonaws.com/my-backup-bucket \
--password-file /etc/restic/password.txt \
| pg_restore -U postgres -d mydb --clean --if-exists
Troubleshooting
| Symptom | Diagnostic Command | Common Fix |
|---|---|---|
| "repository not initialized" | restic cat config --repo <repo> | Run restic init --repo <repo> first |
| "wrong password" | Check env vars / password file | Verify RESTIC_PASSWORD_FILE contents and permissions |
| Backup is slow | restic backup -v for progress | Check network bandwidth; exclude large unneeded dirs |
| S3 permission denied | aws s3 ls s3://bucket/ | Check IAM policy includes s3:GetObject, s3:PutObject |
| "unable to create lock" | restic unlock --repo <repo> | A previous backup crashed; unlock the repository |
| Restore shows empty dirs | restic ls <snapshot-id> | Verify correct snapshot ID; check --include path syntax |
| Repository growing too large | restic stats --repo <repo> | Run restic forget --prune with stricter retention |
| Check fails with pack errors | restic check --read-data | Rebuild index: restic rebuild-index; restore from another copy |
Related Skills
linux-administration-- Server maintenance and log managementsystemd-services-- Scheduling backups with systemd timersobject-storage-- S3 and MinIO as backup destinationsblock-storage-- LVM snapshots for consistent backupsnfs-storage-- Backing up NFS-shared data
FAQ
What does the backup-recovery skill do?
Implement backup and recovery strategies. Configure rsync, Restic, and cloud backups. Use when designing data protection solutions.
How do I install backup-recovery?
Run npx skills add https://github.com/bagelhole/devops-security-agent-skills --skill backup-recovery in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/backup-recovery/ (personal) or .claude/skills/backup-recovery/ (project).
Which AI agents can use backup-recovery?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is backup-recovery safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains backup-recovery?
It is published by bagelhole in bagelhole/devops-security-agent-skills. It has 409 recorded installs.
More from bagelhole/devops-security-agent-skills
linux-hardening
bagelhole/devops-security-agent-skills
Apply CIS benchmarks and secure Linux servers. Configure SSH, manage users, implement firewall rules, and enable security features. Use when hardening Linux systems for production or meeting security compliance requirements.
linux-administration
bagelhole/devops-security-agent-skills
System administration for Linux servers. Manage packages, services, and system configuration. Use when administering Linux systems.
docker-compose
bagelhole/devops-security-agent-skills
Define and run multi-container Docker applications using Docker Compose. Create compose files, manage service dependencies, configure networks and volumes, and orchestrate local development environments. Use when setting up multi-service applications or development environments.
docker-management
bagelhole/devops-security-agent-skills
Build, optimize, and troubleshoot Docker containers and images. Create efficient Dockerfiles, manage container lifecycle, configure networking and volumes, and debug container issues. Use when working with Docker, containerization, or container troubleshooting.
systemd-services
bagelhole/devops-security-agent-skills
Create and manage systemd services and timers. Configure service dependencies and resource limits. Use when managing system services.
reverse-proxy
bagelhole/devops-security-agent-skills
Configure nginx and Traefik as reverse proxies. Implement SSL termination and routing. Use when setting up application gateways.
Popular ai & agents skills
google-agents-cli-publish
google/agents-cli
This skill should be used when the user wants to "publish an agent", "publish my ADK agent", "register an agent with Gemini", "publish to Gemini" (formerly Gemini Enterprise), or needs guidance on the agents-cli publish gemini command. Also use when the user wants to "manage agents in Agent Registry", "list/update/delete registered agents", or "register an MCP server". Covers ADK vs A2A registration modes, programmatic and interactive usage, flag reference, auto-detection from deployment metadata, Agent Registry fleet management, and troubleshooting. Part of the agents-cli skills suite. Do NOT use for deployment (use google-agents-cli-deploy).
google-agents-cli-eval
google/agents-cli
This skill should be used when the user wants to "run an evaluation", "evaluate my agent", "evaluate my ADK agent", "write an eval dataset", "analyze eval failures", "compare eval results", "optimize agent", or needs guidance on the Gemini platform eval methodology and the Quality Flywheel. Covers eval metrics, dataset schema, LLM-as-judge scoring, and common failure causes. Applies to any agents-cli project, whatever framework the agent is written in. Do NOT use for agent API code patterns (ADK: use google-agents-cli-adk-code), deployment (use google-agents-cli-deploy), or project scaffolding (use google-agents-cli-scaffold).
skill-creator
anthropics/skills
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.
codex-pet
prime-skills/runcomfy-agent-skills
Codex Pet generator on RunComfy. Build a Codex-compatible Codex Pet spritesheet.webp + pet.json from a single reference image, drop it into ${CODEXHOME:-$HOME/.codex}/pets/ / and Codex picks it up as a custom Codex Pet next to the 8 built-ins. This skill produces the exact Codex Pet atlas Codex expects (1536x1872 PNG/WebP, 8 cols x 9 rows, 192x208 cells, 9 animation states — idle, running-right, running-left, waving, jumping, failed, waiting, running, review). Calls OpenAI GPT Image 2 edit ONCE via the local RunComfy CLI as runcomfy run openai/gpt-image-2/edit to produce a canonical Codex Pet pose, then assembles all 9 animation rows programmatically with ImageMagick micro-transforms — no Codex Pro, no $imagegen, no OPENAIAPIKEY required, only RUNCOMFYTOKEN. Triggers on "codex pet", "create codex pet", "make codex pet", "hatch codex pet", "/hatch image", "desktop pet codex", "codex pets", "spritesheet.webp", or any explicit ask to build a custom pet for OpenAI Codex.
full-output-enforcement
leonxlnx/taste-skill
Overrides default LLM truncation behavior. Enforces complete code generation, bans placeholder patterns, and handles token-limit splits cleanly. Apply to any task requiring exhaustive, unabridged output.
executing-plans
obra/superpowers
Use when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available