Skip to content

feat(docker): backup OpenSPP filestore (#66)#304

Open
Tarekchehahde wants to merge 1 commit into
OpenSPP:19.0from
Tarekchehahde:feat/66-filestore-backup
Open

feat(docker): backup OpenSPP filestore (#66)#304
Tarekchehahde wants to merge 1 commit into
OpenSPP:19.0from
Tarekchehahde:feat/66-filestore-backup

Conversation

@Tarekchehahde

Copy link
Copy Markdown

Summary

  • Extend docker/backup.sh to tar the Odoo filestore (/odoo_data/filestore/<db>) after each database dump.
  • Mount odoo_data read-only on the backup service in production compose files.
  • Apply the same retention policy to *_filestore_*.tar.gz archives.

Test plan

  • Run backup container with odoo_data mounted; confirm *_filestore_*.tar.gz appears in /backups/daily
  • Confirm backup still works when filestore path is absent (logs skip message)

Fixes #66

Made with Cursor

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>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread docker/backup.sh
Comment on lines +61 to +63
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}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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.

Suggested change
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Backup: Add OpenSPP filestore backup

1 participant