Skip to Content

How to set up automatic backups in Odoo?

June 13, 2026 by

Regular backups are a key part of managing an Odoo system. Automating the process keeps your data safe and eliminates the risk of losing valuable business information. In this article, we present a comprehensive guide to setting up automatic backups in Odoo for the latest versions of the system.

Why are automatic backups essential?

Before you start the configuration, it is worth understanding why automatic backups matter so much for every organization using Odoo:

  • Protection against data loss - hardware failures, human error, or cyberattacks can happen at any time
  • Business continuity - the ability to restore the system quickly minimizes downtime
  • Regulatory compliance - many industries require regular data archiving (GDPR, SOX, HIPAA)
  • Time savings - automation eliminates the need to create backups manually
  • Data versioning - the ability to return to earlier system states in case of erroneous operations

If you don't yet know how to back up an Odoo database manually, it is worth getting familiar with the basics first.

Method 1: Automatic backups in Odoo.sh

For Odoo.sh users, the automatic backup process is as simple as it gets, because the platform offers built-in backup mechanisms.

Configuration in Odoo.sh

Odoo.sh automatically creates backups of production databases according to your subscription plan:

  • Daily backups are kept for 7 days
  • Weekly backups are kept for 4 weeks
  • Monthly backups are archived for 3 months
  • Environment snapshots are created automatically before every deployment

All backups are automatically encrypted and stored in a secure, redundant cloud infrastructure. The Odoo.sh platform stores both the PostgreSQL database and the filestore directory with attachments. No additional configuration is required on your part.

Important: With the Enterprise plan, you can also create additional on-demand backups manually through the Odoo.sh interface and download them for local storage. The backup restore function is available directly from the Odoo.sh dashboard.

Method 2: Automatic backups for on-premise installations

If Odoo is installed on your own server or VPS, you need to set up the automatic backup system yourself. Remember that a full Odoo backup consists of two elements: the PostgreSQL database and the filestore directory containing attachments.

Using a Python script

The most popular method is to create a Python script that automatically creates backups using the Odoo API. Here is a sample script with error handling:

import xmlrpc.client
import base64
import os
import socket
from datetime import datetime

# Configuration
url = 'http://localhost:8069'
db_name = 'database_name'
# NOTE: This is the master_pwd from the odoo.conf configuration file, NOT the user password!
master_password = 'master_password_from_odoo_conf'
backup_dir = '/path/to/backups'

# Create the directory if it does not exist
os.makedirs(backup_dir, exist_ok=True)

try:
    # Connect to Odoo with a timeout
    socket.setdefaulttimeout(300)  # 5-minute timeout for large databases
    sock = xmlrpc.client.ServerProxy(f'{url}/xmlrpc/2/db')
    
    # Create a file name with the date
    filename = f"backup_{db_name}_{datetime.now().strftime('%Y%m%d_%H%M%S')}.zip"
    
    # Run the backup (includes database + filestore)
    print(f"Starting backup creation: {filename}")
    backup_data = sock.dump(master_password, db_name, 'zip')
    
    # Save the file
    backup_path = os.path.join(backup_dir, filename)
    with open(backup_path, 'wb') as f:
        f.write(base64.b64decode(backup_data))
    
    # Verify the file size
    file_size = os.path.getsize(backup_path)
    print(f"Backup created: {filename} ({file_size / 1024 / 1024:.2f} MB)")
    
    # Remove backups older than 30 days
    import time
    current_time = time.time()
    for f in os.listdir(backup_dir):
        file_path = os.path.join(backup_dir, f)
        if os.path.isfile(file_path):
            if os.stat(file_path).st_mtime < current_time - 30 * 86400:
                os.remove(file_path)
                print(f"Removed old backup: {f}")
                
except xmlrpc.client.Fault as err:
    print(f"XML-RPC error: {err}")
    exit(1)
except Exception as e:
    print(f"Error while creating backup: {e}")
    exit(1)

Important technical notes:

  • The master_password parameter is the master password from the Odoo configuration file (admin_passwd or master_pwd), NOT the administrative user's password
  • The 'zip' format includes both the database and the filestore directory with attachments
  • For large databases (>10GB) the process may take several minutes - adjust the timeout accordingly
  • Make sure the user running the script has write permissions to the backup directory

Scheduling with Cron

After creating the script, you need to set up a cron job that will run it automatically. Edit the crontab with the command:

crontab -e

Add an entry for daily backups at 2:00 AM:

0 2 * * * /usr/bin/python3 /path/to/script/backup_odoo.py >> /var/log/odoo_backup.log 2>&1

Other useful schedules:

  • Every 6 hours: 0 */6 * * *
  • Daily at midnight: 0 0 * * *
  • Every Sunday at 3:00 AM: 0 3 * * 0
  • On the first day of the month: 0 2 1 * *
  • On weekdays at 11:00 PM: 0 23 * * 1-5

Try Odoo for free

Method 3: Auto Backup module

For users who prefer solutions with a graphical interface, the "Database Auto-Backup" module from the OCA (Odoo Community Association) is available.

Installing and configuring the module

Step 1: Downloading and installing the module

The module is available in the OCA repository on GitHub. For Odoo 17/18:

  • Download the 'auto_backup' module from the appropriate branch (17.0 or 18.0) of the OCA/server-tools repository
  • Place the module in the addons directory of your Odoo installation
  • Update the apps list (Developer Mode → Update Apps List)
  • Install the "Database Auto-Backup" module

Step 2: Configuring backups

After installation, go to Settings → Technical → Database Structure → Automatic Backups (or use the search bar and type "backup")

Create a new backup configuration with the following parameters:

  • Host name: localhost (for a local installation) or the server's IP address
  • Port: 8069 (or your custom Odoo port)
  • Database name: select the database to back up (the current one is detected automatically)
  • Backup directory: path to the storage directory (e.g. /opt/odoo/backups)
  • Backup frequency: choose the interval (Daily, Weekly, Monthly)
  • Backup time: the time the backup runs (preferably outside working hours)
  • Days to keep: the number of days to retain backups (e.g. 30)
  • Backup type: ZIP (includes database + filestore) or SQL (database only)

Important: The module requires a scheduled action, which is activated by default after installation. Check in Settings → Technical → Automation → Scheduled Actions that the "Backup scheduler" action is active.

The module automatically removes older backups according to the configured retention policy, keeping only the specified number of the most recent backups.

Method 4: PostgreSQL-level backup

For advanced users, there is also the option of creating backups directly at the PostgreSQL level. Note: This method additionally requires a separate backup of the filestore directory!

The pg_dump script

Create a bash script that uses pg_dump:

#!/bin/bash
DATE=$(date +%Y%m%d_%H%M%S)
BACKUP_DIR="/var/backups/odoo"
DB_NAME="database_name"
DB_USER="odoo"
FILESTORE_DIR="/opt/odoo/.local/share/Odoo/filestore/$DB_NAME"

# Create the directory if it does not exist
mkdir -p $BACKUP_DIR

echo "Starting database backup..."
# Database backup (custom format - compression + faster restore)
pg_dump -U $DB_USER -F c -b -v -f "$BACKUP_DIR/db_$DB_NAME_$DATE.dump" $DB_NAME

if [ $? -eq 0 ]; then
    echo "Database backup completed successfully"
else
    echo "Error during database backup!"
    exit 1
fi

echo "Starting filestore backup..."
# Filestore backup (attachments, files)
tar -czf "$BACKUP_DIR/filestore_$DB_NAME_$DATE.tar.gz" -C "$(dirname $FILESTORE_DIR)" "$(basename $FILESTORE_DIR)"

if [ $? -eq 0 ]; then
    echo "Filestore backup completed successfully"
else
    echo "Error during filestore backup!"
    exit 1
fi

# Optionally: combine both backups into one archive
echo "Creating final archive..."
tar -czf "$BACKUP_DIR/full_backup_$DB_NAME_$DATE.tar.gz" \
    -C "$BACKUP_DIR" \
    "db_$DB_NAME_$DATE.dump" \
    "filestore_$DB_NAME_$DATE.tar.gz"

# Remove temporary files
rm "$BACKUP_DIR/db_$DB_NAME_$DATE.dump"
rm "$BACKUP_DIR/filestore_$DB_NAME_$DATE.tar.gz"

# Remove backups older than 30 days
find $BACKUP_DIR -name "full_backup_*.tar.gz" -mtime +30 -delete

echo "Backup completed: full_backup_$DB_NAME_$DATE.tar.gz"
echo "Size: $(du -h $BACKUP_DIR/full_backup_$DB_NAME_$DATE.tar.gz | cut -f1)"

Critical notes:

  • A backup of the PostgreSQL database alone does NOT include attachments! You must archive the filestore directory separately
  • The default filestore location is ~/.local/share/Odoo/filestore/[database_name] for the Odoo user
  • The custom format (-F c) in pg_dump offers the best compression and is recommended for production backups
  • Make sure the user has read permissions for the filestore directory
  • To restore, you need both the database dump and the filestore archive

Add this script to crontab in the same way as in method 2. Make sure you have given it execute permissions:

chmod +x /path/to/script/backup_odoo.sh

Contact us

Storing backups in the cloud

It is best practice to store backups in different locations, including the cloud. You can use:

  • AWS S3: Set up synchronization using the AWS CLI - it offers versioning and encryption
  • Google Cloud Storage: Use gsutil for automatic synchronization with version control
  • Microsoft Azure Blob Storage: Ideal for enterprise environments with AD integration
  • Backblaze B2: An economical alternative with S3 compatibility
  • FTP/SFTP: Set up transfer to a remote server (less secure, SFTP recommended)
  • Rsync: Fast and efficient incremental synchronization to a remote server

Example of synchronization with AWS S3 using encryption:

# Synchronization with server-side encryption
aws s3 sync /path/to/backups s3://bucket-name/odoo-backups/ \
    --storage-class STANDARD_IA \
    --server-side-encryption AES256 \
    --delete

Example of using rclone for Google Drive:

# After configuring rclone (rclone config)
rclone sync /path/to/backups gdrive:OdooBackups \
    --transfers 4 \
    --checkers 8 \
    --contimeout 60s \
    --timeout 300s \
    --retries 3

Testing the restore process

Creating a backup is only half the battle - regularly testing the restore process is just as important. A backup that has not been tested is not a backup!

We recommend:

  • Regular tests: Run restore tests at least once a quarter (preferably monthly)
  • Test environment: Restore the backup to a separate test instance, not to production
  • Documenting the procedure: A detailed description of the restore steps, including execution time
  • Integrity verification: Check the MD5/SHA256 checksums of the backup files
  • Functional testing: After restoring, check key functions: login, reports, attachments, integrations
  • Time measurement: Measure how long a full restore takes - crucial for your RTO (Recovery Time Objective)
  • Disaster scenarios: Practice different scenarios: data loss, database corruption, cyberattack

To learn more about the data recovery process, read our article on how to restore an Odoo database from a backup.

Try Odoo for free

Backup security best practices

To ensure maximum security for your backups:

  • Encryption at rest: Always encrypt backups, especially those stored in the cloud (AES-256)
  • Encryption in transit: Use SSL/TLS when transferring backups (HTTPS, SFTP, not FTP)
  • The 3-2-1 rule: Keep 3 copies of your data, on 2 different types of media, with 1 copy off-site
  • Immutable backups: Use write-once-read-many (WORM) mechanisms or Object Lock in S3
  • Access restriction: Set restrictive permissions (chmod 600) on backup directories
  • Password rotation: Regularly change the master_pwd password in the Odoo configuration
  • Monitoring: Set up notifications for backup failures
  • Air gap: Consider offline/cold storage for critical backups (protection against ransomware)
  • Documentation: Keep thorough documentation of procedures, schedules, and responsible persons
  • Compliance: Make sure your backup strategy meets the requirements of GDPR, ISO 27001, or other standards

Monitoring and notifications

Set up a notification system that will inform you about the status of your backups. You can achieve this through:

  • Email alerts: Sending summaries after each backup (use the SMTP configuration in Odoo)
  • Integration with monitoring systems: Nagios, Zabbix, Prometheus + Grafana
  • Webhook notifications: Notifications to Slack, Microsoft Teams, Discord
  • SMS alerts: For critical backup errors (Twilio, AWS SNS)
  • Logging: Centralized logging with rotation (syslog, ELK stack)
  • Healthchecks.io: Simple "dead man's switch" monitoring - no signal = problem

Example of extending the script with email notifications:

# Add at the end of the backup script
if [ $? -eq 0 ]; then
    echo "Backup successful: $filename" | mail -s "[OK] Odoo Backup Success" admin@example.com
else
    echo "Backup FAILED! Check logs immediately." | mail -s "[CRITICAL] Odoo Backup FAILED" admin@example.com
fi

FAQ - Frequently asked questions

How often should automatic backups be created in Odoo?

The backup frequency depends on how intensively the system is used and on your organization's RPO (Recovery Point Objective). For companies with a high number of daily transactions and a low RPO (1-4 hours), we recommend backups every 4-6 hours. For mid-sized companies, 1-2 backups a day are enough. Small organizations can limit themselves to daily night-time backups. Always create additional backups before major system updates, data migrations, or configuration changes. For critical environments, consider real-time PostgreSQL replication.

Where should Odoo backups be stored securely?

The best practice is to follow the 3-2-1-1-0 strategy: 3 copies of your data, on 2 different types of media, with 1 off-site copy, 1 offline (air-gapped) copy, and 0 verification errors. In practice this means: (1) a local backup server within your infrastructure, (2) a public cloud (AWS S3, Google Cloud Storage, Azure) with encryption and versioning, (3) an offline copy on tapes or removable disks stored physically off-premises. All copies must be encrypted with AES-256. For GDPR compliance, pay attention to the geographic location where data is stored (EU regions).

Do automatic backups affect Odoo performance?

Yes, creating backups can significantly affect system performance, especially with large databases (>50GB). A backup of the full database and filestore generates a high disk I/O and memory load. That is why it is recommended to run backups during the hours of lowest load (2-4 AM). For very large databases (>100GB), consider: (1) PostgreSQL streaming replication with backups taken from the replica, not the master, (2) Incremental backups instead of full ones (pg_basebackup + WAL archiving), (3) Storage-level snapshots (LVM, ZFS, AWS EBS), which are practically instantaneous. For Enterprise installations in the cloud, consider using managed backup services (AWS RDS automated backups, Azure Database for PostgreSQL).

Does the Auto Backup module work with Odoo 17 and 18?

Yes, the "Database Auto-Backup" module from OCA is regularly updated and available for Odoo 17 and 18. However, you must make sure you download the module version that matches your Odoo version (from the 17.0 or 18.0 branch). The module is compatible with both Odoo Community and Enterprise Edition. Remember that after every major Odoo upgrade, it is worth checking whether the module needs to be updated.

How can I check whether my backups include the filestore?

It depends on the backup method. If you use the Odoo API (the XML-RPC method) with the ZIP format, the filestore is included automatically. If you back up only with pg_dump, the filestore is NOT included and you must archive it separately (by default in ~/.local/share/Odoo/filestore/). To check the contents of a ZIP backup from Odoo, extract it and check whether it contains a 'filestore' folder. You can also compare sizes: a database-only backup will be much smaller than a backup with the filestore (which can be very large if you store many documents/images).

Summary

Setting up automatic backups in Odoo is a key element of ensuring the security of company data and business continuity. Whichever method you choose - the built-in mechanisms of Odoo.sh, Python scripts with cron, dedicated modules, or PostgreSQL-level backups - regular automatic backups protect your organization from losing valuable information.

Key takeaways:

  • A full Odoo backup requires archiving both the PostgreSQL database and the filestore directory
  • Test the restore process regularly - an untested backup is worthless
  • Use the 3-2-1 strategy with at least one off-site copy (preferably in the cloud)
  • Encrypt all backups and secure access with restrictive permissions
  • Monitor the backup process and set up alerts for failures
  • Adjust the backup frequency to your RPO and the rate of data changes

Remember that a well-planned backup strategy is not only a matter of technology, but also of processes, documentation, and team training. In the event of a failure, every minute counts - make sure your organization is prepared.

Need help setting up automatic Odoo backups? The KK Innovations team specializes in implementing and administering Odoo systems. Contact us for professional support with data security, backup configuration, disaster recovery planning, and optimization of your Odoo environment. We will make sure your data is always safe, available, and compliant with the highest industry standards!

Contact us