feat(docker): backup OpenSPP filestore (#66)#304
Conversation
Archive filestore alongside pg_dump when odoo_data is mounted on the backup container; document restore expectations in docker README. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Code Review
This pull request introduces automated filestore backups for Odoo by mounting the odoo_data volume to the backup service and updating the backup script to archive attachments daily, weekly, and monthly, alongside cleaning up expired archives. The reviewer pointed out a critical issue where running the tar command directly under set -e could cause the entire backup script to abort if files are modified during archiving. They suggested wrapping the tar command in an if statement to handle failures gracefully and clean up partial archives.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| tar -czf "${DAILY_DIR}/${FILESTORE_BACKUP_FILE}" -C "$(dirname "${FILESTORE_SRC}")" "$(basename "${FILESTORE_SRC}")" | ||
| ln -sf "${FILESTORE_BACKUP_FILE}" "${DAILY_DIR}/${PGDATABASE:-openspp}_filestore_latest.tar.gz" | ||
| echo "[$(date -Iseconds)] Filestore backup complete: ${FILESTORE_BACKUP_FILE}" |
There was a problem hiding this comment.
Running tar directly under set -e can cause the entire backup script to abort if any files are modified or deleted while the archiving process is running (which is common for active filestores). If tar exits with a non-zero status, the script will terminate immediately, preventing subsequent steps like weekly/monthly copies and old backup cleanup from executing.
Wrapping the tar command in an if statement safely handles potential non-zero exit codes without triggering set -e. Additionally, if the archiving fails, we should clean up any partial/corrupt tarball to prevent it from being treated as a valid backup or copied to weekly/monthly directories.
| tar -czf "${DAILY_DIR}/${FILESTORE_BACKUP_FILE}" -C "$(dirname "${FILESTORE_SRC}")" "$(basename "${FILESTORE_SRC}")" | |
| ln -sf "${FILESTORE_BACKUP_FILE}" "${DAILY_DIR}/${PGDATABASE:-openspp}_filestore_latest.tar.gz" | |
| echo "[$(date -Iseconds)] Filestore backup complete: ${FILESTORE_BACKUP_FILE}" | |
| if tar -czf "${DAILY_DIR}/${FILESTORE_BACKUP_FILE}" -C "$(dirname "${FILESTORE_SRC}")" "$(basename "${FILESTORE_SRC}")"; then | |
| ln -sf "${FILESTORE_BACKUP_FILE}" "${DAILY_DIR}/${PGDATABASE:-openspp}_filestore_latest.tar.gz" | |
| echo "[$(date -Iseconds)] Filestore backup complete: ${FILESTORE_BACKUP_FILE}" | |
| else | |
| echo "[$(date -Iseconds)] Error: Filestore backup failed. Cleaning up partial archive..." >&2 | |
| rm -f "${DAILY_DIR}/${FILESTORE_BACKUP_FILE}" | |
| fi |
Summary
docker/backup.shto tar the Odoo filestore (/odoo_data/filestore/<db>) after each database dump.odoo_dataread-only on the backup service in production compose files.*_filestore_*.tar.gzarchives.Test plan
odoo_datamounted; confirm*_filestore_*.tar.gzappears in/backups/dailyFixes #66
Made with Cursor