跳到正文
Skillpedia
部署与云(DevOps)48k · #5335

odoo-backup-strategy

它能做什么

这个工具可以帮你为 Odoo 系统创建备份(安全副本),包括重要数据和文件。如果出了问题,它还会指导你如何完整恢复。

适用场景

  • ✓需要为 Odoo 搭建备份系统时。
  • ✓想要自动完成每日备份时。
  • ✓Odoo 无法正常运行或数据损坏时。

技能链接

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

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/odoo-backup-strategy/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“帮我设置 Odoo 的自动每日备份,并把备份上传到云端。”

每周 5 个新技能,1 分钟读完。

工作原理

你告诉我你的 Odoo 服务器配置,我会编写一个用于备份的脚本。如果需要恢复数据,我会提供分步说明。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Odoo Backup Strategy

Overview

A complete Odoo backup must include both the PostgreSQL database and the filestore (attachments, images). This skill covers manual and automated backup procedures, offsite storage, and the correct restore sequence to bring a down Odoo instance back online.

When to Use This Skill

  • Setting up a backup strategy for a production Odoo instance.
  • Automating daily backups with shell scripts and cron.
  • Restoring Odoo after a server failure or data corruption event.
  • Diagnosing a failed backup or corrupt restore.

How It Works

  1. Activate: Mention @odoo-backup-strategy and describe your server environment.
  2. Generate: Receive a complete backup script tailored to your setup.
  3. Restore: Get step-by-step restore instructions for any failure scenario.

Examples

Example 1: Manual Database + Filestore Backup

#!/bin/bash
# backup_odoo.sh

DATE=$(date +%Y%m%d_%H%M%S)
DB_NAME="odoo"
DB_USER="odoo"
FILESTORE_PATH="/var/lib/odoo/.local/share/Odoo/filestore/$DB_NAME"
BACKUP_DIR="/backups/odoo"

mkdir -p "$BACKUP_DIR"

# Step 1: Dump the database
pg_dump -U $DB_USER -Fc $DB_NAME > "$BACKUP_DIR/db_$DATE.dump"

# Step 2: Archive the filestore
tar -czf "$BACKUP_DIR/filestore_$DATE.tar.gz" -C "$FILESTORE_PATH" .

echo "✅ Backup complete: db_$DATE.dump + filestore_$DATE.tar.gz"

Example 2: Automate with Cron (daily at 2 AM)

# Run: crontab -e
# Add this line:
0 2 * * * /opt/scripts/backup_odoo.sh >> /var/log/odoo_backup.log 2>&1

Example 3: Upload to S3 (after backup)

# Add to backup script after tar command:
aws s3 cp "$BACKUP_DIR/db_$DATE.dump"        s3://my-odoo-backups/db/
aws s3 cp "$BACKUP_DIR/filestore_$DATE.tar.gz" s3://my-odoo-backups/filestore/

# Optional: Delete local backups older than 7 days
find "$BACKUP_DIR" -type f -mtime +7 -delete

Example 4: Full Restore Procedure

# Step 1: Stop Odoo
docker compose stop odoo  # or: systemctl stop odoo

# Step 2: Recreate and restore the database
# (--clean alone fails if the DB doesn't exist; drop and recreate first)
dropdb -U odoo odoo 2>/dev/null || true
createdb -U odoo odoo
pg_restore -U odoo -d odoo db_YYYYMMDD_HHMMSS.dump

# Step 3: Restore the filestore
FILESTORE=/var/lib/odoo/.local/share/Odoo/filestore/odoo
rm -rf "$FILESTORE"/*
tar -xzf filestore_YYYYMMDD_HHMMSS.tar.gz -C "$FILESTORE"/

# Step 4: Restart Odoo
docker compose start odoo

# Step 5: Verify — open Odoo in the browser and check:
#   - Can you log in?
#   - Are recent records visible?
#   - Are file attachments loading?

Best Practices

  • ✅ Do: Test restores monthly in a staging environment — a backup you've never restored is not a backup.
  • ✅ Do: Follow the 3-2-1 rule: 3 copies, 2 different media types, 1 offsite copy (e.g., S3 or a remote server).
  • ✅ Do: Back up immediately before every Odoo upgrade — this is your rollback point.
  • ✅ Do: Verify backup integrity: pg_restore --list backup.dump should complete without errors.
  • ❌ Don't: Back up only the database without the filestore — all attachments and images will be missing after a restore.
  • ❌ Don't: Store backups on the same disk or same server as Odoo — a disk or server failure destroys both.
  • ❌ Don't: Run pg_restore --clean against a non-existent database — always create the database first.

Limitations

  • Does not cover Odoo.sh built-in backups — Odoo.sh has its own backup system accessible from the dashboard.
  • This script assumes a single-database Odoo setup. Multi-database instances require looping over all databases.
  • Filestore path may differ between installations (Docker volume vs. bare-metal). Always verify the path with odoo-bin shell before running a restore.
  • Large filestores (100GB+) may require incremental backup tools like rsync or restic rather than full tar.gz archives.
常见问题

什么是“filestore”?

它是 Odoo 保存你上传的所有文件的地方,比如图片和附件文档。

为什么不应该把备份存放在运行 Odoo 的同一台服务器上?

如果服务器出故障,Odoo 和备份都会一起丢失。最好在其他地方保存一份副本。

需要测试备份是否有效吗?

需要!定期测试恢复非常重要,这样才能确保备份是可用的。

详情

作者的原始描述

Complete Odoo backup and restore strategy: database dumps, filestore backup, automated scheduling, cloud storage upload, and tested restore procedures.

repo: sickn33/agentic-awesome-skills

热度

GitHub 星标
48k
排名
#5335
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能