Skip to Content

Backup & Disaster Recovery

Automatic Odoo backups kept off the server, with tested restores, so a failed disk or a bad upgrade does not cost you your data.

WHAT IS BACKED UP

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.

EVERY NIGHT

How a backup runs

Nightly backup: the schedule starts the script, each database and filestore is saved, old copies are removed, a copy goes off-site and the result is sent to Telegram. 02:30cron starts pg_dumpeach database tar filestoreattachments Off-site copyother provider Old copiesremoved after success Telegramβœ… or ❌
Old backups are deleted only after the new one has finished successfully.
HOW IT IS IMPLEMENTED

Scripts, schedule and alerts

Excerpts from the backup system running on a live Odoo server.

  1. 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
  2. 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 rclone
    rclone copy "$DEST" "offsite:odoo-backups/$(basename "$DEST")"
    rclone delete --min-age 30d offsite:odoo-backups   # keep 30 days off-site
  3. 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-backup
    30 2 * * * root /odoo/scripts/backup-notify.sh erp.example.com \
      /odoo/logs/backup.log /odoo/scripts/backup.sh
    n8n Β· Backup result β†’ Telegram
    n8n workflow that receives the backup result and sends it to Telegram
    The n8n workflow behind the alert: receive the result, format a short message, send it to Telegram.
  4. 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.

  5. 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 drill
    B=/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"
EXAMPLE SCHEDULE

Kept on and off the server

BackupWhenKept
DailyEvery night14 days
WeeklySunday8 weeks
Off-server copyEvery nightYour choice
Before changesEach upgradeUntil checked

Times and retention are set to match your data size and storage budget.

IF SOMETHING GOES WRONG

Recovery plan

  1. Deleted records or a bad import: restore yesterday's copy as a separate database and copy back only what was lost.
  2. Failed upgrade: restore the backup taken just before it.
  3. Lost server: build a new server from the written setup and restore the off-site copy.
  4. After every recovery: a short report of what happened and what was changed.
HOW YOU BENEFIT

Sleep well about your data

🧾Proof every morning

A message tells you last night's backup worked, with its size.

⏱️Known recovery time

The restore drill measures how long getting back takes.

🌍Safe from a lost server

The off-site copy survives even if the provider loses the machine.

A backup you have never restored is only a guess. That is why every setup ends with a real restore, not just a backup file.
QUESTIONS

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.