Skip to content
Odoo Migration

Odoo Migration: Managing Database Backups and Recovery Points

A practical guide to securing Odoo databases during migration, covering backup strategies, restore testing, recovery points, and rollback planning to ensure data integrity and operational continuity.

6 min readSysGenPro Editorial
Odoo Migration: Managing Database Backups and Recovery Points

Direct Answer: Securing Odoo Data Through Layered Backups and Verified Recovery Points

Managing database backups and recovery points during an Odoo migration is the primary control mechanism for preventing data loss and ensuring operational continuity. The recommended approach involves creating a layered backup strategy that captures the PostgreSQL database, file attachments, configuration files, and static assets at defined intervals before, during, and after the migration. This is critical because Odoo migrations, particularly version upgrades, involve schema changes, code modifications, and data transformations that can introduce inconsistencies or corruption. The main risks to control include irreversible data loss due to failed upgrades, downtime exceeding business tolerance, and the inability to roll back to a known good state if critical errors occur. By establishing verified recovery points and testing restore procedures in a staging environment, organizations can mitigate these risks and ensure that the migration can be halted and reversed if necessary.

Understanding the Scope of Odoo Data Assets

A common misconception in Odoo migrations is that backing up the database is sufficient. In reality, Odoo stores critical business data in multiple locations. The PostgreSQL database contains transactional data, such as sales orders, invoices, and customer records. However, file attachments, such as PDFs, images, and documents linked to records, are stored in the file system, typically under the data directory. Additionally, configuration files, such as odoo.conf, and static assets, such as custom themes and JavaScript files, are stored separately. A comprehensive backup strategy must account for all these components. Failing to back up file attachments can result in a database that references missing files, leading to broken links and data integrity issues in the post-migration environment.

Database vs. File System Components

The database backup should be a logical dump or a physical snapshot, depending on the size of the database and the required recovery time. Logical dumps are portable and easier to verify but can be slower for large databases. Physical snapshots are faster but require the same PostgreSQL version for restore. File system backups should include the entire data directory, ensuring that all attachments and static files are captured. It is essential to maintain the directory structure and permissions to ensure that the Odoo service can access these files after a restore.

Pre-Migration Backup Strategy and Recovery Point Objectives

Before initiating the migration, establish a baseline backup of the production environment. This backup serves as the primary rollback point. Define the Recovery Point Objective (RPO), which is the maximum acceptable amount of data loss measured in time. For most ERP migrations, an RPO of zero or near-zero is desired, meaning that the backup should reflect the state of the system immediately before the migration begins. To achieve this, stop the Odoo service and any scheduled jobs to ensure that no new transactions are written to the database during the backup process. This quiescent state ensures that the backup is consistent and free from partial transactions.

Defining Recovery Time Objectives

Alongside the RPO, define the Recovery Time Objective (RTO), which is the maximum acceptable time to restore the system and resume operations. The RTO depends on the size of the database and the complexity of the restore process. For example, restoring a 100GB database may take several hours, while a 10GB database may take less than an hour. The RTO should be aligned with the business downtime window. If the business cannot tolerate more than four hours of downtime, the RTO must be less than four hours. This may require using physical backups or parallel restore processes to meet the RTO.

Executing the Backup Process

The backup process should be automated and documented to ensure consistency and repeatability. Use standard PostgreSQL tools, such as pg_dump for logical backups or pg_basebackup for physical backups. For logical backups, use the --format=custom option to enable parallel restore and compression. For physical backups, ensure that the backup is stored on a separate storage system to protect against hardware failure. After the database backup, copy the file system components, including the data directory and configuration files. Use checksums, such as SHA-256, to verify the integrity of the backup files. Store the checksums in a secure location for later verification.

ComponentBackup MethodFrequencyVerification Method
PostgreSQL DatabaseLogical Dump (pg_dump)Pre-migration, Post-migrationChecksum Verification, Restore Test
File AttachmentsFile System CopyPre-migration, Post-migrationChecksum Verification, File Count Comparison
Configuration FilesFile System CopyPre-migrationManual Review, Checksum Verification
Static AssetsFile System CopyPre-migrationChecksum Verification

Testing Restore Procedures in a Staging Environment

A backup is only as good as its ability to be restored. Before the production migration, test the restore procedure in a staging environment that mirrors the production setup. This includes the same PostgreSQL version, operating system, and Odoo version. Restore the database backup and file system components to the staging environment. Start the Odoo service and verify that the system boots correctly. Check for any errors in the logs and ensure that key business processes, such as creating a sales order or generating an invoice, function as expected. This test validates that the backup is complete and that the restore process is reliable.

Validating Data Integrity After Restore

After the restore, perform data integrity checks to ensure that the data is consistent. Use SQL queries to check for orphaned records, such as invoices without associated sales orders. Verify that sequences are synchronized and that no duplicate records exist. Compare the record counts in the restored database with the production database to ensure that no data was lost during the backup or restore process. These checks help identify any issues that may have been introduced during the backup or restore process.

Managing Recovery Points During Migration

During the migration, create additional recovery points at critical stages. For example, create a recovery point after the database schema upgrade but before the data transformation. This allows you to roll back to the schema-upgraded state if the data transformation fails. Create another recovery point after the data transformation but before the code deployment. This allows you to roll back to the data-transformed state if the code deployment fails. Each recovery point should be a complete backup of the database and file system components. Label each recovery point with a timestamp and a description of the stage it represents.

Automating Recovery Point Creation

Written by
SysGenPro Editorial

SysGenPro Editorial

Platform & solutions team

Practical guidance on ERP, AI automation, cloud deployment and enterprise transformation from the SysGenPro team.

Share this article
Continue learning
View all articles
Explore the platform

Where to go next

Browse the knowledge hub

See how SysGenPro fits your business

Discuss your workflows, modules and deployment options with our team.

Back to resources