askill
backup

backupSafety 72Repository

Backup and restore — files, databases, and system backups

3 stars
1.2k downloads
Updated 3/1/2026

Package Files

Loading files...
SKILL.md

Backup

Backup and restore files, databases, and systems.

File Backups

rsync (Incremental)

# Basic sync
rsync -av /source/ /backup/

# With progress
rsync -av --progress /source/ /backup/

# Exclude patterns
rsync -av --exclude 'node_modules' --exclude '.git' --exclude '*.log' /source/ /backup/

# Remote backup
rsync -avz -e ssh /source/ user@remote:/backup/

# Delete files not in source (mirror)
rsync -av --delete /source/ /backup/

# Dry run
rsync -av --dry-run /source/ /backup/

# Backup with date
rsync -av --backup --backup-dir=/backup/$(date +%Y%m%d) /source/ /backup/current/

tar Archives

# Create archive
tar -czvf backup.tar.gz /path/to/backup/

# With exclude
tar -czvf backup.tar.gz --exclude='*.log' --exclude='node_modules' /path/

# Split large archives
tar -czvf - /path/ | split -b 1G - backup.tar.gz.

# Verify archive
tar -tzvf backup.tar.gz

# Extract
tar -xzvf backup.tar.gz -C /destination/

# Incremental tar
tar --create --file=backup.tar --listed-incremental=backup.snar /path/

Database Backups

PostgreSQL

# Full backup
pg_dump -h localhost -U user dbname > backup.sql

# Compressed
pg_dump -h localhost -U user dbname | gzip > backup.sql.gz

# All databases
pg_dumpall -U postgres > all_databases.sql

# Custom format (better for large DBs)
pg_dump -h localhost -U user -Fc dbname > backup.dump

# Restore from SQL
psql -h localhost -U user dbname < backup.sql

# Restore from custom format
pg_restore -h localhost -U user -d dbname backup.dump

MySQL

# Single database
mysqldump -u user -p dbname > backup.sql

# All databases
mysqldump -u user -p --all-databases > all_databases.sql

# With gzip
mysqldump -u user -p dbname | gzip > backup.sql.gz

# Specific tables
mysqldump -u user -p dbname table1 table2 > tables.sql

# Restore
mysql -u user -p dbname < backup.sql

MongoDB

# Export database
mongodump --uri="mongodb://user:pass@host/dbname" --out=backup/

# Export specific collection
mongodump --uri="mongodb://host/dbname" --collection=users --out=backup/

# Import database
mongorestore --uri="mongodb://host/dbname" backup/dbname/

# Export to JSON
mongoexport --uri="mongodb://host/dbname" --collection=users --out=users.json

Automated Backups

Cron Job

# Edit crontab
crontab -e

# Daily backup at 2 AM
0 2 * * * rsync -av /source/ /backup/ >> /var/log/backup.log 2>&1

# Weekly full backup
0 3 * * 0 tar -czvf /backup/weekly-$(date +\%Y\%m\%d).tar.gz /source/

# Monthly database backup
0 4 1 * * pg_dump -U user dbname | gzip > /backup/db-$(date +\%Y\%m).sql.gz

Backup Script

#!/bin/bash
# backup.sh

DATE=$(date +%Y%m%d_%H%M%S)
BACKUP_DIR="/backup/$DATE"
SOURCE="/data"

mkdir -p "$BACKUP_DIR"

# Files
rsync -av "$SOURCE/" "$BACKUP_DIR/files/"

# Database
pg_dump -U user mydb | gzip > "$BACKUP_DIR/database.sql.gz"

# Cleanup old backups (keep last 7)
find /backup -type d -mtime +7 -exec rm -rf {} \;

echo "Backup completed: $BACKUP_DIR"

Cloud Backup

AWS S3

# Sync to S3
aws s3 sync /local/ s3://bucket/backup/

# With glacier storage
aws s3 sync /local/ s3://bucket/backup/ --storage-class GLACIER

# Restore from S3
aws s3 sync s3://bucket/backup/ /local/

rclone (Multi-cloud)

# Setup
rclone config

# Sync to Google Drive
rclone sync /local/ gdrive:backup/

# Sync to Dropbox
rclone sync /local/ dropbox:backup/

# Encrypted backup
rclone sync /local/ crypt:backup/

Tips

  • Use --dry-run before running backups
  • Test restore procedures regularly
  • Keep multiple backup generations
  • Encrypt sensitive backups
  • Store offsite or in cloud

Triggers

backup, restore, rsync, database backup, file backup, pg_dump, mysqldump, archive

Install

Download ZIP
Requires askill CLI v1.0+

AI Quality Score

90/100Analyzed 2/19/2026

High-quality technical reference skill covering file, database, and cloud backup methods. Provides extensive working commands for rsync, tar, PostgreSQL, MySQL, MongoDB, AWS S3, and rclone. Well-structured with metadata (version, author, tags, category). Includes automation examples (cron, scripts) and practical tips. The Triggers section serves as effective 'when to use' guidance. Scores bonus on multiple rules for structured content, metadata, and dedicated skills folder location. Minor gaps include encryption implementation details and more explicit safety warnings."

72
88
88
75
85

Metadata

Licenseunknown
Version0.1.0
Updated3/1/2026
Publisherjholhewres

Tags

databasetesting