← 返回
未分类

Backup Rotator

Smart backup rotation and retention manager. Create backups, enforce flexible retention policies (grandfather-father-son), verify integrity, and clean up old...
智能备份轮换与保留管理器。创建备份,执行灵活的保留策略(祖父-父-子),校验完整性,并清理旧的...
ericlooi504
未分类 clawhub v1.0.0 1 版本 99586.8 Key: 无需
★ 0
Stars
📥 241
下载
💾 0
安装
1
版本
#latest

概述

Backup Rotator

Create, rotate, and verify backups with configurable retention policies. Uses only Python standard library — no pip install needed.

Quick start

# Create a backup
python3 skills/backup-rotator/scripts/backup_rotator.py --backup /path/to/source /path/to/backups

# Create backup with compress
python3 skills/backup-rotator/scripts/backup_rotator.py --backup /path/to/dir /backups --compress

# List existing backups
python3 skills/backup-rotator/scripts/backup_rotator.py --list /backups --name myproject

# Rotate (clean old backups)
python3 skills/backup-rotator/scripts/backup_rotator.py --rotate /backups --name myproject

# Dry run (see what would be deleted)
python3 skills/backup-rotator/scripts/backup_rotator.py --rotate /backups --name myproject --dry-run

# Verify backup integrity
python3 skills/backup-rotator/scripts/backup_rotator.py --verify /backups

Retention Policy (default)

CategoryKeepDescription
-----------------------------
Daily7Most recent daily backups
Weekly4Most recent Sunday backups
Monthly3First 7 days of each month
Old0Beyond all retention → deleted

Default policy keeps 14 backups minimum.

Config File (for cron)

Create a JSON config file for fully automated backup + rotation:

{
  "backup_source": "/var/lib/postgresql/database.dump",
  "backup_dest": "/backups/db",
  "backup_name": "postgres",
  "keep_daily": 7,
  "keep_weekly": 4,
  "keep_monthly": 3,
  "compress": true,
  "verify": true
}

Then run:

python3 skills/backup-rotator/scripts/backup_rotator.py --cron config.json

Output:

  Backup Rotator — 2026-05-10 13:30:00
  ==================================================
  Name prefix:       postgres
  Keep daily:        7
  Keep weekly:       4
  Keep monthly:      3
  Compress:          yes
  Verify:            yes

  📦 Creating backup...
  Compressing /var/lib/postgresql/database.dump → /backups/db/postgres_20260510-133000.tar.gz
  Size:    42.3M
  SHA256:  a1b2c3d4e5f6...

  🔄 Rotating old backups...
  Summary: 12 keep, 3 delete
  Keeping:
    ✅ postgres_20260510-133000.tar.gz (42.3M) - keep (daily)
    ✅ postgres_20260509-020000.tar.gz (41.8M) - keep (daily)
    ...
  Deleting:
    🗑  postgres_20260428-020000.tar.gz (40.1M) - delete (past retention)

  ✅ Verifying remaining backups...
  ✅ postgres_20260510-133000.tar.gz SHA256: a1b2...
  ✅ postgres_20260509-020000.tar.gz SHA256: b2c3...

Common commands

CommandAction
-----------------
--backup SOURCE DESTCreate timestamped backup
--list DIRList all backups with age and category
--rotate DIRApply retention policy, delete old backups
--dry-runPreview rotation without deleting
--verify DIRCheck SHA256 checksums of all backups
--cron config.jsonFull automated run: backup + rotate + verify
--name PREFIXFilter backup files by name prefix
--compressCompress directory backups to tar.gz
--no-verifySkip SHA256 verification

Automation with Cron

Add to crontab for daily automated backups:

# Daily at 2am
0 2 * * * cd /home/user && python3 skills/backup-rotator/scripts/backup_rotator.py --cron /home/user/configs/backup-postgres.json >> /var/log/backup-rotator.log 2>&1

Requirements

  • Python 3.6+ (no pip install needed)
  • Uses only standard library: os, shutil, hashlib, json, argparse
  • Works on Linux, macOS (partial)
  • No external API calls — fully offline

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-05-11 05:13 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

Price Monitor

ericlooi504
在 Shopee、Lazada、Amazon 等平台上自动追踪竞争对手产品价格,设置提醒并生成详细对比报告。
★ 0 📥 371

Python Automation

ericlooi504
全栈 Python 自动化工具包,用于文件处理、数据抽取、PDF 操作、Excel/工作表自动化、网页爬取以及系统任务。使用 w...
★ 0 📥 427

Docker Ops

ericlooi504
Docker 容器生命周期管理、健康检查、日志分析、清理、Docker Compose 编排与故障排查。用于 Codex 需要管理 Docker 时。
★ 0 📥 364