agentleFS
28672032962867203296/hermes-agent/skills/devops/backup-strategies/SKILL.md

backup-strategies

Skill0 starsChanged 3 months agoMITView on GitHub

备份策略:3-2-1原则、数据库备份、Git备份、自动化脚本.

  • Reads credentials
  • Commits and pushes

The file

Files
SKILL.md

备份策略

3-2-1 原则

3 份副本
2 种不同介质(本地硬盘 + 云端)
1 份异地备份

例子:
- 本地:日常文件
- NAS:自动同步
- 云:加密后上传(异地)

数据库备份

# PostgreSQL
pg_dump mydb > backup_$(date +%Y%m%d).sql
pg_dump -Fc mydb > backup.dump  # 压缩格式

# MySQL
mysqldump -u user -p mydb > backup.sql

# SQLite(最简单)
cp database.db "backup_$(date +%Y%m%d).db"
sqlite3 database.db ".backup 'backup.db'"
# 自动化备份脚本
import subprocess, datetime
from pathlib import Path

def backup_db():
    today = datetime.date.today().isoformat()
    backup_path = Path(f"backups/db_{today}.sql")

    subprocess.run([
        "pg_dump", "mydb",
        "-f", str(backup_path)
    ], check=True)

    # 保留最近7天
    for old in sorted(Path("backups").glob("db_*.sql"))[:-7]:
        old.unlink()

Git 备份

Git 本身就是分布式备份!

但要注意:
- Git 不存大文件(视频/数据集)
- Git 不存密钥(.env 不提交)
- 定期 git push(等于云端备份)

备份内容清单

必须备份:
□ 数据库
□ 代码(git push)
□ 配置文件(非密钥)
□ 用户上传的文件
□ Obsidian 知识库(你今天写的!)

不必备份:
✗ 依赖包(能重新装)
✗ 缓存/临时文件
✗ 构建产物

恢复测试

备份的意义不是"备份了"
而是"能恢复"

每季度做一次恢复演练:
1. 从备份恢复数据库
2. 验证数据完整性
3. 记录恢复时间

没测过恢复的备份 = 没有备份

你的环境

D:\Hermes\ → 最重要!代码+技能+知识库
→ 定期复制到移动硬盘(不同介质)
→ 加密上传云盘(异地)
→ Git push 到 GitHub(远程备份)

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.