• Thursday, January 22, 2026

In the realm of enterprise resource planning, Odoo stands out as a leading open-source system, renowned for its flexibility and comprehensive features. Built on Python and utilizing PostgreSQL as its database backend, Odoo efficiently manages a vast array of business operations. Given its central role in storing critical business data, establishing a reliable and automated backup strategy for your Odoo databases is not merely a recommendation but an absolute necessity. Regular database backups are your primary defense against unforeseen data loss, system failures, or accidental deletions, ensuring the continuity and integrity of your operations.

This tutorial will guide you through the essential steps to implement automatic daily backups for your Odoo databases. We will explore both the user-friendly Odoo database management interface and powerful command-line methods, culminating in a robust, automated backup solution using cron jobs.

Odoo Database Management Interface

Odoo provides a convenient web-based database management interface that offers a straightforward way to manage your databases, including operations such as backing up, duplicating, deleting, creating, and restoring. For those who prefer a graphical approach, creating a backup through this interface is a simple and intuitive process. To access this tool, open your web browser and navigate to the following URL, replacing your_server_ip with the actual IP address or domain name of your Odoo instance:

http://your_server_ip:8069/web/database/manager

Upon reaching the database manager page, you will typically find a list of your Odoo databases. To initiate a backup, locate and click on the Backup link associated with the specific database you wish to secure. This action will prompt a new popup window to appear, requesting further details.

In the popup, you will need to enter your Odoo database Master Password and select the desired backup format. Once provided, click on the blue Backup button to start the process. The system will then begin generating a compressed archive of your database. Depending on the size and complexity of your Odoo database, this backup procedure may take some time to complete. Once finished, your browser will download the generated backup file, typically in a .zip format.

Creating a Database Backup from the Command Line

While the Odoo database management interface offers a user-friendly way to create backups, automating this process requires a command-line approach. Fortunately, the same underlying Odoo tool can be invoked programmatically using command-line utilities like wget or curl. Both of these powerful tools are capable of sending HTTP POST requests, which allows us to pass the necessary variables directly to Odoo's database backup mechanism.

Below, we will illustrate how to perform a database backup from the command line. In our examples, ADMIN_PASSWORD represents your Odoo Master Password, DB_NAME is the name of the database you intend to back up, and backup_dir specifies the directory where the backup file, named back_up_filename.zip, will be saved.

Using curl for Command-Line Backup

The curl command is a versatile tool for transferring data with URL syntax. Here’s how you can use it to create an Odoo database backup:

curl -X POST -F "master_pwd=ADMIN_PASSWORD" -F "name=DB_NAME" -F "backup_format=zip" -o "backup_dir/back_up_filename.zip" http://localhost:8069/web/database/backup

Using wget for Command-Line Backup

Alternatively, if you prefer using wget, which is another robust utility for retrieving content from web servers, you can achieve the same result with the following command:

wget --post-data "master_pwd=ADMIN_PASSWORD&name=DB_NAME&backup_format=zip" -O "backup_dir/back_up_filename.zip" http://localhost:8069/web/database/backup

It is important to adjust the ADMIN_PASSWORD, DB_NAME, and the output path backup_dir/back_up_filename.zip to match your specific Odoo setup. When creating a backup from a remote location rather than localhost, you must specify the full URL to your Odoo instance. For security reasons, especially when transmitting sensitive information like your master password, it is highly recommended to use HTTPS to encrypt the communication.

Automating Backups with Cron Jobs

To ensure that your Odoo database is regularly protected, the backup process needs to be automated. This can be effectively achieved by leveraging cron jobs, a time-based job scheduler in Unix-like operating systems. Cron allows you to schedule commands or scripts to run automatically at specified intervals.

Let's consider a practical scenario: we want to back up our Odoo database every day at 01:30 am and maintain a retention policy of keeping only the latest 7 backup files. To accomplish this, we will create a simple yet effective bash script.

First, create a new file for your backup script. You can name it descriptively, for example, odoo_daily_backup.sh, and place it in a suitable directory like /opt/odoo/scripts/:

#!/bin/bash

# Configuration variables - PLEASE UPDATE THESE!
BACKUP_DIR="/opt/odoo/backups"         # Directory where backups will be stored
ODOO_DATABASE="your_odoo_database"     # Your specific Odoo database name
ADMIN_PASSWORD="your_odoo_master_password" # Your Odoo master password

# Ensure backup directory exists
mkdir -p "${BACKUP_DIR}"

# Generate a timestamp for the backup file
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
BACKUP_FILE="${BACKUP_DIR}/${ODOO_DATABASE}_${TIMESTAMP}.zip"

echo "Starting Odoo database backup for ${ODOO_DATABASE}..."

# Execute the backup using curl
curl -X POST -F "master_pwd=${ADMIN_PASSWORD}" \
     -F "name=${ODOO_DATABASE}" \
     -F "backup_format=zip" \
     -o "${BACKUP_FILE}" \
     "http://localhost:8069/web/database/backup"

if [ $? -eq 0 ]; then
    echo "Backup for ${ODOO_DATABASE} created successfully: ${BACKUP_FILE}"
    # Clean up old backups: Keep only the latest 7 files
    echo "Cleaning up old backups..."
    find "${BACKUP_DIR}" -name "${ODOO_DATABASE}_*.zip" -type f -printf '%T@ %p\n' | sort -nr | tail -n +8 | awk '{print $2}' | xargs -r rm -v
    echo "Old backups cleaned."
else
    echo "Error: Odoo database backup failed for ${ODOO_DATABASE}."
fi

After creating the script, make it executable using the chmod command:

chmod +x /opt/odoo/scripts/odoo_daily_backup.sh

It is crucial to remember to modify the BACKUP_DIR, ODOO_DATABASE, and ADMIN_PASSWORD variables within the script to align with your specific environment and Odoo configuration before proceeding.

The final step in automating this process is to set up a new cron job. Open your crontab for editing by typing crontab -e in your terminal. Then, add the following line to schedule the script to run daily at 01:30 am:

30 1 * * * /opt/odoo/scripts/odoo_daily_backup.sh

Ensure that you specify the correct and absolute path to your backup script in the cron entry. This setup will ensure that your Odoo database is backed up daily, providing peace of mind and data security. You can further enhance this script to implement more sophisticated backup solutions, such as integrating with remote cloud storage, maintaining weekly or monthly archives, or incorporating more advanced error handling mechanisms.

Restoring an Odoo Database

In the event of data loss or system migration, restoring an Odoo database from a backup is as crucial as creating the backup itself. Odoo provides methods for restoration through both its web management interface and the command line, offering flexibility based on your preference and operational needs.

Restoring via the Management Interface

To restore a database using the Odoo database management interface, navigate once again to your Odoo instance's database manager in your web browser:

http://your_server_ip:8069/web/database/manager

On this page, locate and click the Restore Database button. A new popup window will appear, prompting you to provide the necessary details for the restoration.

Within the popup, you will need to enter your Odoo database Master Password. Then, select the backup file (.zip archive) from your local system, and provide a new name for the database that will be created during the restoration. It's important to note that if a database with the chosen name already exists, you will either need to delete the existing database or choose a different name for the new one. Once all details are correctly filled, click on the blue Continue button to initiate the restoration. The time required for the restoration process will vary depending on the database size and your internet connection speed.

Restoring from the Command Line

For automated or server-side restoration, the command line offers a powerful alternative. You can use curl to post the backup file and restoration parameters directly to the Odoo instance. Here is an example of how to restore a database from the command line:

curl -X POST -F "master_pwd=ADMIN_PASSWORD" -F "backup_file=@/path/to/your/backup_file.zip" -F "new_db_name=NEW_DB_NAME" http://localhost:8069/web/database/restore

Ensure you replace ADMIN_PASSWORD with your Odoo Master Password, /path/to/your/backup_file.zip with the actual path to your backup archive, and NEW_DB_NAME with the desired name for your newly restored database. As with command-line backups, employing HTTPS is strongly advised when performing restorations from remote locations to protect sensitive data.

If the restoration process is successful, you will typically receive an output indicating the completion of the operation. A common success message might resemble this:

Database restored successfully

This confirms that your Odoo database has been successfully recovered and is ready for use under the new name.

Conclusion

This comprehensive tutorial has walked you through the critical process of setting up and managing Odoo database backups. We have covered methods ranging from the user-friendly Odoo database management interface to efficient command-line operations using curl and wget, culminating in the automation of daily backups through cron jobs. Implementing these strategies is fundamental for safeguarding your valuable Odoo data against potential loss and ensuring the smooth, uninterrupted operation of your business processes. By regularly backing up and knowing how to restore your Odoo databases, you establish a resilient foundation for your enterprise's data integrity and operational continuity.