[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-a7d2bc6b-7ce3-4a63-b693-36d0951c4d1f":3,"$fWSzJu1glxxsm8Qeg4VraYHnuagtOIT8hlaG8ArknMMs":43},{"id":4,"title":5,"description":6,"categoryId":7,"moduleId":8,"tags":9,"prompt":10,"icon":11,"source":12,"sourceUrl":13,"authorId":14,"authorName":15,"isPublic":16,"stars":17,"runs":18,"createdAt":19,"updatedAt":19,"module":20,"category":27,"packages":34},"a7d2bc6b-7ce3-4a63-b693-36d0951c4d1f","odoo-backup-strategy","完整的Odoo备份和恢复策略：数据库转储、文件存储备份、自动调度、云存储上传和测试恢复流程。","cat_life_career","mod_other","sickn33,other","---\nname: odoo-backup-strategy\ndescription: \"Complete Odoo backup and restore strategy: database dumps, filestore backup, automated scheduling, cloud storage upload, and tested restore procedures.\"\nrisk: safe\nsource: \"self\"\n---\n\n# Odoo Backup Strategy\n\n## Overview\n\nA 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.\n\n## When to Use This Skill\n\n- Setting up a backup strategy for a production Odoo instance.\n- Automating daily backups with shell scripts and cron.\n- Restoring Odoo after a server failure or data corruption event.\n- Diagnosing a failed backup or corrupt restore.\n\n## How It Works\n\n1. **Activate**: Mention `@odoo-backup-strategy` and describe your server environment.\n2. **Generate**: Receive a complete backup script tailored to your setup.\n3. **Restore**: Get step-by-step restore instructions for any failure scenario.\n\n## Examples\n\n### Example 1: Manual Database + Filestore Backup\n\n```bash\n#!\u002Fbin\u002Fbash\n# backup_odoo.sh\n\nDATE=$(date +%Y%m%d_%H%M%S)\nDB_NAME=\"odoo\"\nDB_USER=\"odoo\"\nFILESTORE_PATH=\"\u002Fvar\u002Flib\u002Fodoo\u002F.local\u002Fshare\u002FOdoo\u002Ffilestore\u002F$DB_NAME\"\nBACKUP_DIR=\"\u002Fbackups\u002Fodoo\"\n\nmkdir -p \"$BACKUP_DIR\"\n\n# Step 1: Dump the database\npg_dump -U $DB_USER -Fc $DB_NAME > \"$BACKUP_DIR\u002Fdb_$DATE.dump\"\n\n# Step 2: Archive the filestore\ntar -czf \"$BACKUP_DIR\u002Ffilestore_$DATE.tar.gz\" -C \"$FILESTORE_PATH\" .\n\necho \"✅ Backup complete: db_$DATE.dump + filestore_$DATE.tar.gz\"\n```\n\n### Example 2: Automate with Cron (daily at 2 AM)\n\n```bash\n# Run: crontab -e\n# Add this line:\n0 2 * * * \u002Fopt\u002Fscripts\u002Fbackup_odoo.sh >> \u002Fvar\u002Flog\u002Fodoo_backup.log 2>&1\n```\n\n### Example 3: Upload to S3 (after backup)\n\n```bash\n# Add to backup script after tar command:\naws s3 cp \"$BACKUP_DIR\u002Fdb_$DATE.dump\"        s3:\u002F\u002Fmy-odoo-backups\u002Fdb\u002F\naws s3 cp \"$BACKUP_DIR\u002Ffilestore_$DATE.tar.gz\" s3:\u002F\u002Fmy-odoo-backups\u002Ffilestore\u002F\n\n# Optional: Delete local backups older than 7 days\nfind \"$BACKUP_DIR\" -type f -mtime +7 -delete\n```\n\n### Example 4: Full Restore Procedure\n\n```bash\n# Step 1: Stop Odoo\ndocker compose stop odoo  # or: systemctl stop odoo\n\n# Step 2: Recreate and restore the database\n# (--clean alone fails if the DB doesn't exist; drop and recreate first)\ndropdb -U odoo odoo 2>\u002Fdev\u002Fnull || true\ncreatedb -U odoo odoo\npg_restore -U odoo -d odoo db_YYYYMMDD_HHMMSS.dump\n\n# Step 3: Restore the filestore\nFILESTORE=\u002Fvar\u002Flib\u002Fodoo\u002F.local\u002Fshare\u002FOdoo\u002Ffilestore\u002Fodoo\nrm -rf \"$FILESTORE\"\u002F*\ntar -xzf filestore_YYYYMMDD_HHMMSS.tar.gz -C \"$FILESTORE\"\u002F\n\n# Step 4: Restart Odoo\ndocker compose start odoo\n\n# Step 5: Verify — open Odoo in the browser and check:\n#   - Can you log in?\n#   - Are recent records visible?\n#   - Are file attachments loading?\n```\n\n## Best Practices\n\n- ✅ **Do:** Test restores monthly in a staging environment — a backup you've never restored is not a backup.\n- ✅ **Do:** Follow the **3-2-1 rule**: 3 copies, 2 different media types, 1 offsite copy (e.g., S3 or a remote server).\n- ✅ **Do:** Back up **immediately before every Odoo upgrade** — this is your rollback point.\n- ✅ **Do:** Verify backup integrity: `pg_restore --list backup.dump` should complete without errors.\n- ❌ **Don't:** Back up only the database without the filestore — all attachments and images will be missing after a restore.\n- ❌ **Don't:** Store backups on the same disk or same server as Odoo — a disk or server failure destroys both.\n- ❌ **Don't:** Run `pg_restore --clean` against a non-existent database — always create the database first.\n\n## Limitations\n\n- Does not cover **Odoo.sh built-in backups** — Odoo.sh has its own backup system accessible from the dashboard.\n- This script assumes a **single-database** Odoo setup. Multi-database instances require looping over all databases.\n- Filestore path may differ between installations (Docker volume vs. bare-metal). Always verify the path with `odoo-bin shell` before running a restore.\n- Large filestores (100GB+) may require incremental backup tools like `rsync` or `restic` rather than full `tar.gz` archives.\n","","imported","https:\u002F\u002Fgithub.com\u002Fsickn33\u002Fantigravity-awesome-skills","user_system_seed","SkillOPIC",true,51,788,"2026-05-16 13:31:56",{"id":8,"name":21,"slug":22,"icon":23,"description":24,"sort":25,"createdAt":26},"其他","other","mdi-page-next-outline","其他类型Skill",5,"2026-05-16 12:53:40",{"id":7,"name":28,"slug":29,"icon":30,"description":31,"moduleId":8,"sort":32,"skillCount":33,"createdAt":26},"职场发展","career","mdi-briefcase-outline","面试准备、简历优化、职业规划",4,575,[35],{"id":36,"skillId":4,"version":37,"fileName":38,"fileSize":39,"filePath":40,"fileHash":41,"manifest":42,"createdAt":19},"2a903630-8729-42aa-9b09-3f31e13f33d7","1.0.0","odoo-backup-strategy.zip",2048,"uploads\u002Fskills\u002Fa7d2bc6b-7ce3-4a63-b693-36d0951c4d1f\u002Fodoo-backup-strategy.zip","9a5ffd150833ac54fcd06f225fd0601bfa77560f4e48a19ae338959d2a5d8c1a","[{\"path\":\"SKILL.md\",\"isDirectory\":false,\"size\":4178}]",{"code":44,"message":45,"data":46},200,"success",{"items":47,"stats":48,"page":51},[],{"averageRating":49,"totalRatings":49,"ratingCounts":50},0,[49,49,49,49,49],{"limit":52,"offset":49,"hasMore":53,"nextOffset":52,"ratedOnly":16},15,false]