Chuyển đến nội dung
Skillpedia
Triển khai và đám mây (DevOps)48k · #4010

backup-recovery

Skill này làm gì

Công cụ này giúp bạn tạo bản sao lưu an toàn cho dữ liệu quan trọng và khôi phục khi có sự cố. Nó dùng các chương trình như rsync và Restic để lưu tệp ở những nơi an toàn, như ổ đĩa khác hoặc đám mây.

Khi nào nên dùng

  • ✓Khi bạn muốn bảo vệ các tệp quan trọng khỏi bị mất.
  • ✓Khi thiết lập hệ thống tự động lưu bản sao lưu.
  • ✓Khi bạn cần khôi phục các tệp đã bị xóa hoặc hỏng.

Liên kết skill

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/backup-recovery/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/backup-recovery/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Thiết lập sao lưu tự động cho tài liệu của tôi lên đám mây, dùng Restic.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Công cụ cấu hình các công cụ để sao chép tệp của bạn sang một vị trí khác. Bạn có thể đặt tần suất sao lưu và cách sắp xếp, bảo vệ tệp để có thể khôi phục sau này.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

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

  • rsync installed (included in most Linux distributions)
  • restic installed (v0.16+ recommended)
  • Cloud CLI configured for the backend: AWS CLI for S3, b2 CLI for Backblaze B2
  • Sufficient storage at the backup destination (2-3x source size for retention)
  • SSH access for remote rsync targets
  • systemd or cron for 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 \

…
Câu hỏi thường gặp

Quy tắc 3-2-1 là gì?

Đây là khuyến nghị an toàn: giữ 3 bản sao dữ liệu, trên 2 loại phương tiện lưu trữ khác nhau, với 1 bản sao ở ngoài địa điểm (ví dụ trên đám mây).

Khác biệt giữa rsync và Restic là gì?

Rsync phù hợp để sao chép đơn giản, nhanh, đặc biệt giữa các máy tính. Restic nâng cao hơn, có mã hóa, nén và tiết kiệm dung lượng, phù hợp cho sao lưu chắc chắn và an toàn hơn.

Tôi có cần biết lập trình để dùng không?

Bạn không cần là lập trình viên giàu kinh nghiệm. Hướng dẫn cung cấp các lệnh rõ ràng, bạn có thể sao chép và điều chỉnh cho nhu cầu sao lưu của mình.

Chi tiết

Mô tả gốc của tác giả

Implement backup and recovery strategies. Configure rsync, Restic, and cloud backups. Use when designing data protection solutions.

repo: sickn33/agentic-awesome-skills

Độ phổ biến

Sao GitHub
48k
Vị trí xếp hạng
#4010
Giấy phép
MIT
Cập nhật
15/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự