Everything needed to rebuild your Odoo
A database copy alone is not enough: without the filestore, every attachment, product image and scanned document is lost.
Database
All records: customers, invoices, stock, settings and users, as a compressed PostgreSQL dump.
Filestore
Attachments, images and documents, packed with the database they belong to.
Server setup
Docker, nginx and Odoo configuration, so a replacement server can be built quickly.
How a backup runs
Scripts, schedule and alerts
Excerpts from the backup system running on a live Odoo server.
-
Back up every database and its files
The script finds every Odoo database, dumps it and packs its filestore. It works in a temporary folder, so a failed run never replaces a good backup.
/odoo/scripts/backup.sh (excerpt)set -Eeuo pipefail STAMP=$(date +%Y%m%d-%H%M%S) DEST="/odoo/backups/$STAMP"; WORK="$DEST.partial" mkdir -p "$WORK"; trap 'rm -rf "$WORK"' ERR dbs=$(docker compose exec -T db psql -U "$POSTGRES_USER" -d postgres -Atc \ "SELECT datname FROM pg_database WHERE datistemplate = false AND datname <> 'postgres'") for db in $dbs; do docker compose exec -T db pg_dump -U "$POSTGRES_USER" -Fc "$db" > "$WORK/$db.dump" [[ -s "$WORK/$db.dump" ]] || { echo "empty dump for $db" >&2; false; } tar -C /odoo/data/filestore -czf "$WORK/$db-filestore.tar.gz" "$db" done mv "$WORK" "$DEST" # only now does the new backup count -
Copy it off the server
A backup on the same disk does not survive a lost server. A second copy goes to storage at another provider (S3-compatible storage, Backblaze B2, Google Drive and others).
Off-site copy with rclonerclone copy "$DEST" "offsite:odoo-backups/$(basename "$DEST")" rclone delete --min-age 30d offsite:odoo-backups # keep 30 days off-site -
Schedule it and report every result
The schedule runs a wrapper that keeps a log and sends the result, size and disk usage to Telegram.
/etc/cron.d/odoo-backup30 2 * * * root /odoo/scripts/backup-notify.sh erp.example.com \ /odoo/logs/backup.log /odoo/scripts/backup.sh
The n8n workflow behind the alert: receive the result, format a short message, send it to Telegram. -
Back up before every change
Module upgrades start with a fresh backup and stop if it fails, so there is always a copy from minutes before the change.
-
Test the restore
A recent backup is restored into a separate test database and switched to safe mode, so it cannot send emails or run scheduled jobs.
Restore drillB=/odoo/backups/20261121-023000 docker compose exec -T db createdb -U "$POSTGRES_USER" restore_test docker compose exec -T db pg_restore -U "$POSTGRES_USER" -d restore_test --no-owner < "$B/mydb.dump" mkdir -p /tmp/fs && tar -C /tmp/fs -xzf "$B/mydb-filestore.tar.gz" mv /tmp/fs/mydb /odoo/data/filestore/restore_test # no emails, no scheduled jobs, no payments from the copy docker compose exec odoo odoo neutralize -d restore_test \ --db_host db --db_user "$POSTGRES_USER" --db_password "$POSTGRES_PASSWORD"
Kept on and off the server
Times and retention are set to match your data size and storage budget.
Recovery plan
- Deleted records or a bad import: restore yesterday's copy as a separate database and copy back only what was lost.
- Failed upgrade: restore the backup taken just before it.
- Lost server: build a new server from the written setup and restore the off-site copy.
- After every recovery: a short report of what happened and what was changed.
Sleep well about your data
A message tells you last night's backup worked, with its size.
The restore drill measures how long getting back takes.
The off-site copy survives even if the provider loses the machine.
Common questions
Does Odoo not back itself up?
Not on your own server. The database manager can download a backup by hand, but nothing runs on a schedule, checks the result or keeps a copy elsewhere.
Where should the off-site copy go?
Any storage at a different provider from your server. For a typical Odoo database it costs a few dollars per month.
Can you restore a single deleted record?
Yes. Yesterday's backup is restored as a separate database and only the missing records are copied back.
