Technical

Odoo Backup Guide: Database, Filestore, Off-Site Copies and Restores

A practical guide to backing up a self-hosted Odoo: dump the database and filestore together, ship copies off the server, pick a schedule, test restores, and write a one-page disaster-recovery plan.

Kalvyai Engineering · · 7 min read

Odoo Backup Guide: Database, Filestore, Off-Site Copies and Restores (cover)
On this page

Most Odoo backup problems are found on the day someone needs the backup. The database dump is there, but the attachments are missing. Or the only copy sits on the same disk that just failed. Or nobody has ever tried a restore, and it turns out to take a full day.

This post covers a backup setup for a self-hosted Odoo that holds up when something goes wrong. It covers what to back up, where to keep it, how often to run it, how to test it, and how to write a short recovery plan.

What an Odoo backup actually contains

An Odoo instance keeps its data in two places. A backup needs both.

  1. The PostgreSQL database. Records live here: partners, invoices, stock moves, users, settings.
  2. The filestore. By default, attachments are stored as files on disk, not in the database. This covers uploaded documents, generated PDFs, product images and many website assets. The database only holds a reference to each file.

The filestore lives under the data_dir set in your Odoo configuration file, in a folder named after the database:

Plain text
<data_dir>/filestore/<database_name>/

On many Linux package installs this is under /var/lib/odoo. Source installs often use ~/.local/share/Odoo for the user that runs Odoo. Check the data_dir line in your own config before you write any script. If it is not set, Odoo uses its default.

If you restore a database without its filestore, Odoo still starts. Records open normally. But attachments, images and some assets fail to load, and the server logs fill with file-not-found errors. That is why a database dump on its own is not a full Odoo backup.

Other things worth keeping

If the server disappears, these items save hours:

  • The Odoo config file (odoo.conf or similar). It contains the master password and database credentials, so encrypt the backup.
  • Your custom and third-party addons. Ideally these already live in git, with the exact commit you run in production recorded.
  • The Odoo version and source commit, plus the Python dependency list.
  • Reverse proxy config (for example nginx), systemd unit files and cron jobs.
  • Any secrets you need to reconnect integrations: payment provider keys, mail server credentials, API tokens. Keep these in a password manager, not in the backup folder in plain text.

The database manager backup and its limits

Odoo's web database manager (/web/database/manager) can download a backup as a zip file. The zip holds the SQL dump and the filestore. It can also produce a pg_dump file without the filestore.

For a small database this is a fine way to take a one-off copy. For routine backups it has drawbacks:

  • It runs through the web server, so large databases can hit timeouts.
  • It needs the master password, and the manager page has to be reachable.
  • It is manual unless you script it.

On a production server, many admins disable the manager with list_db = False and set a strong admin_passwd. Scheduled backups then run on the server itself with pg_dump and a copy of the filestore, as below.

A simple backup script

This script dumps the database first and copies the filestore right after. The order matters. Odoo periodically removes filestore files that are no longer referenced. If you copy the filestore long before or after the dump, you can end up with a database pointing to files you did not capture. Keep the gap between the two steps short.

Bash
#!/usr/bin/env bash
set -euo pipefail

DB_NAME="production"                               # your database name
DATA_DIR="/var/lib/odoo"                           # must match data_dir in your config
ODOO_CONF="/etc/odoo/odoo.conf"                    # path to your config file
BACKUP_ROOT="/var/backups/odoo"
STAMP="$(date +%Y%m%d-%H%M%S)"
DEST="${BACKUP_ROOT}/${STAMP}"

mkdir -p "$DEST"

# 1. Database (custom format: compressed, restorable with pg_restore)
pg_dump --format=custom --no-owner --file="${DEST}/${DB_NAME}.dump" "$DB_NAME"

# 2. Filestore, immediately after
tar -C "${DATA_DIR}/filestore" -czf "${DEST}/filestore.tar.gz" "$DB_NAME"

# 3. Config and checksums
cp "$ODOO_CONF" "${DEST}/"
( cd "$DEST" && sha256sum * > SHA256SUMS )

echo "Backup written to ${DEST}"

Run it as a user that can connect to the database and read the filestore, usually the same system user Odoo runs as. A cron entry for a nightly run looks like this:

Plain text
30 2 * * * /usr/local/bin/odoo-backup.sh >> /var/log/odoo-backup.log 2>&1

Add a check that alerts someone when the script fails or when no new backup appears. A backup job that has silently failed for three weeks is a common finding.

Get copies off the server

A backup on the same server protects you from a bad import or a deleted record. It does not protect you from a dead disk, a compromised server or a hosting account problem.

A common rule is 3-2-1: three copies of the data, on two different kinds of storage, with one copy off-site. For a self-hosted Odoo that usually means:

  1. The live database and filestore.
  2. A local backup folder on the server, kept for fast restores.
  3. An encrypted copy in object storage or on a separate machine, with a different provider or account than the production server.

Tools such as restic, borg or rclone handle encryption and upload. A restic example:

Bash
export RESTIC_REPOSITORY="s3:<your-storage-endpoint>/odoo-backups"
export RESTIC_PASSWORD_FILE="/root/.restic-password"
# plus the storage access keys for your provider

restic backup "/var/backups/odoo/${STAMP}"

Protect backups from the server itself

If an attacker gets root on the Odoo server, they can use the same credentials to delete your off-site backups. Reduce that risk:

  • Give the server credentials that can write new backups but not delete old ones. Many object storage services support versioning or object lock for this. Check what your provider offers.
  • Run retention and pruning (for example restic forget --prune) from a separate machine that holds the delete permission.
  • Keep the encryption password somewhere other than the server, such as a password manager. Without it, the off-site copy cannot be read.

How often to back up

Two numbers drive the schedule:

  • RPO (recovery point objective): how much work you can afford to lose. If the server dies at 4 pm and the last backup is from 2 am, you lose a working day of orders and invoices.
  • RTO (recovery time objective): how long the business can run without Odoo while you restore.

A reasonable starting point for many small and mid-size companies:

Activity level

Approach

Low volume, few users

Nightly database + filestore, shipped off-site

Busy sales, POS or warehouse

Nightly full backup plus more frequent database dumps during working hours

Losing hours of data is not acceptable

Continuous PostgreSQL WAL archiving (point-in-time recovery) with a tool such as pgBackRest or WAL-G, plus frequent filestore sync

These are examples, not rules. Agree the RPO and RTO with whoever owns the business risk, then design the schedule to meet them.

Retention

Keep enough history to recover from problems found late, such as a bad data import noticed two weeks after the fact. One common pattern is 7 daily, 4 weekly and 12 monthly copies. Adjust it to your storage budget and any legal retention needs for accounting data.

Also take a manual backup before risky changes: module installs, Odoo version upgrades, bulk imports and large data cleanups.

Test a restore regularly

A backup you have never restored is a guess. Schedule a restore test, for example monthly, on a separate server or VM. Never test on production.

Restore steps

  1. Copy the backup files to the test server and verify checksums with sha256sum -c SHA256SUMS.
  2. Create an empty database and restore the dump:
Bash
createdb -O odoo restore_test
pg_restore --no-owner --role=odoo -d restore_test production.dump
  1. Restore the filestore. The folder name must match the new database name:
Bash
mkdir -p /var/lib/odoo/filestore
tar -C /var/lib/odoo/filestore -xzf filestore.tar.gz
mv /var/lib/odoo/filestore/production /var/lib/odoo/filestore/restore_test
chown -R odoo:odoo /var/lib/odoo/filestore/restore_test
  1. Neutralize the copy before starting Odoo. A restored production database still has active scheduled actions, outgoing mail servers, payment providers and integrations. Start it as-is and it may email customers, charge cards or push stock to your online store. From Odoo 16 onward there is a built-in command:
Bash
odoo-bin neutralize -c /etc/odoo/odoo.conf -d restore_test

On older versions, disable scheduled actions and mail servers yourself before the first start, and review any connector settings:

SQL
UPDATE ir_cron SET active = false;
UPDATE ir_mail_server SET active = false;
-- also disable any other module that calls external services (payment providers, connectors)
  1. Start Odoo on the test server with the same Odoo version and addons as production.

What to check

  • You can log in, and the main apps open.
  • Record counts roughly match production for key tables (sale orders, invoices, stock moves).
  • Attachments open and a PDF report prints.
  • No missing filestore files. This query plus shell loop lists any references without a file:
Bash
psql -d restore_test -At -c "SELECT store_fname FROM ir_attachment WHERE store_fname IS NOT NULL" |
while read -r f; do
  [ -f "/var/lib/odoo/filestore/restore_test/$f" ] || echo "missing: $f"
done

Time the whole restore and write the number down. That is your real RTO, and it is often longer than people assume.

A one-page disaster-recovery plan

When the server is down, nobody wants to work out the steps from memory. Write a short document and keep a copy somewhere that does not depend on the Odoo server. It should answer:

  1. Who decides and who acts. Who declares an incident, who restores, who tells staff and customers. Use roles, with phone numbers kept current.
  2. Where the backups are. Storage location, how to access it, where the encryption password is kept.
  3. What to rebuild on. A new server spec, OS version, PostgreSQL version, Odoo version and the git commit for addons.
  4. Restore steps. The same steps you use in your restore test, written as commands. On a real recovery, skip neutralization, since this becomes production.
  5. Reconnect and cut over. Update DNS or the proxy, check SSL, re-enter any secrets that were not in the backup, and turn on integrations in a controlled order.
  6. Check and reconcile. Compare the last backup time with the incident time. List what was lost (orders, payments, stock moves) and assign someone to re-enter or reconcile it with payment providers and sales channels.
  7. Review. After the incident, note what was slow or missing and update the plan.

Read through the plan during each restore test. If a step no longer matches reality, fix it then.

Quick checklist

  • Database and filestore backed up together, database first.
  • Config, addons and version info stored alongside.
  • Encrypted off-site copy, with delete rights kept off the production server.
  • Schedule based on agreed RPO and RTO.
  • Failure alerts on the backup job.
  • Regular restore tests on a neutralized copy, with timings recorded.
  • A written recovery plan stored outside the server.

How Kalvyai can help

We set up and run self-hosted Odoo for businesses, including backup scripts, off-site storage, restore testing and recovery runbooks that match your actual RPO and RTO. If you want a review of your current setup or help building one, see our Odoo services or contact us. Our Odoo, ERPNext and Shopify apps are listed at store.kalvyai.com.

Share this article

  • Odoo
  • Backups
  • PostgreSQL
  • Disaster Recovery
  • Self-Hosting
  • DevOps

Kalvyai Engineering · Engineering team

The engineers who build, connect and fix business systems at Kalvyai: Odoo, ERPNext, Shopify and AI agents that work inside them with approvals, budgets and an audit trail.

Comments

No comments yet. Questions and corrections are welcome.

Rate this post or leave a comment

Your rating (optional)
Not rated

Comments appear after an editor approves them. See our privacy notice.

Read next

WhatsApp Coexistence for Odoo 19: Setup and User Guide (cover)User guide
Kalvyai EngineeringOdoo

WhatsApp Coexistence for Odoo 19: Setup and User Guide

How to install, connect and use WhatsApp Coexistence for Odoo 19 so your team keeps replying from the WhatsApp Business app while Odoo logs every message on the same number.

7 min read

Newsletter

Get new guides in your inbox.

Practical notes on Odoo, ERPNext, Shopify and AI agents, written by the engineers who build them. No spam, and you can ask to stop at any time.

Prefer a feed? Subscribe by RSS. We use your email only to send new articles. See our privacy policy.