Skip to content
Odoo Migration

Odoo Migration: Migrating Document Management and Attachment Data

A practical guide to migrating Odoo attachments and document management data, covering storage strategies, integrity checks, and risk mitigation for version upgrades.

11 min readSysGenPro Editorial
Odoo Migration: Migrating Document Management and Attachment Data

Direct Answer: How to Migrate Odoo Document Management and Attachment Data

Migrating Odoo document management and attachment data requires a dual-track approach that addresses both the relational database records and the physical binary files stored on the file system or object storage. The recommended approach involves a full database backup, a synchronized file system copy, and a rigorous integrity verification process in a staging environment before production cutover. This migration is critical because attachments often contain legally binding contracts, financial records, and operational documents that, if lost or corrupted, can halt business operations. The primary risks to control are data loss due to incomplete file transfers, broken links between database records and physical files, and performance degradation caused by inefficient storage configurations in the target version. Success depends on verifying that the target Odoo version supports the specific storage backend and that all custom modules interacting with the attachment model are compatible with the new version's API changes.

Assessing Source and Target Version Compatibility

Before initiating any data movement, you must assess the compatibility between your source Odoo version and the target version. Odoo has evolved significantly in how it handles attachments, particularly regarding the storage backend and the structure of the ir_attachment model. In older versions, attachments were often stored directly in the database as binary large objects (BLOBs), while newer versions typically default to file system storage or support cloud storage providers. You must verify whether your target version supports the storage method currently in use. If you are migrating from a version that uses database BLOBs to a version that uses file system storage, a transformation step is required to extract the binary data and write it to the appropriate directory structure. Conversely, if you are moving from file system to database storage, the files must be read and inserted into the database. Always consult the official Odoo release notes for your specific source and target versions to understand any changes to the attachment model, such as changes to the res_model or res_id fields, which link attachments to specific records.

Verifying Custom Module Dependencies

Custom modules that extend the document management functionality are a significant risk factor. Many custom modules override the default attachment behavior, add custom fields to the ir_attachment model, or implement custom search and filtering logic. During an upgrade, these modules may break if they rely on deprecated APIs or if the underlying model structure has changed. You must audit all custom modules that interact with attachments. Check for any direct SQL queries against the ir_attachment table, as these are highly likely to fail if the schema changes. Additionally, verify that any third-party add-ons used for document management, such as e-signature integrations or advanced document workflow tools, are compatible with the target version. If a module is not supported, you must decide whether to rewrite it, replace it with a supported alternative, or disable it during the migration window. Disabling modules that handle attachments can lead to data inconsistency if they are responsible for maintaining links between documents and business records.

Preparing the Storage Infrastructure

The physical location of your attachments is as important as the database records. Odoo supports several storage backends: local file system, Amazon S3, and other cloud storage providers. Your migration strategy must align with your target infrastructure. If you are moving to a new server or cloud environment, you must ensure that the file system permissions are correctly configured for the Odoo service user. The directory structure for attachments is typically defined in the Odoo configuration file (odoo.conf) under the data_dir or filestore path. You must replicate this structure in the target environment. If you are migrating to a cloud storage backend, you must configure the necessary API keys and bucket permissions before the migration. It is critical to test the write and read permissions in the staging environment to ensure that Odoo can create new attachments and retrieve existing ones without permission errors. Failure to configure storage correctly is a common cause of post-migration failures where users can see attachment metadata but cannot download the files.

Choosing the Right Storage Backend

Storage BackendProsConsMigration Consideration
Local File SystemLow latency, simple setup, no external dependenciesSingle point of failure, difficult to scale, backup complexityRequires full directory copy; verify permissions and disk space
Amazon S3High availability, scalable, durable, off-site backupLatency for large files, cost for frequent access, complex configurationRequires API key setup; test network connectivity and bucket policies
Database BLOBSimplified backup (single file), atomic transactionsDatabase bloat, slower performance, limited scalabilityRequires extraction to file system if target version defaults to file storage

Executing the Data Migration Process

The migration execution should follow a strict sequence to ensure data consistency. First, perform a full backup of the source database and a complete copy of the attachment file store. This backup serves as your rollback point. Next, restore the database backup into the target staging environment. If you are changing the storage backend, you must now perform the data transformation. For example, if moving from database BLOBs to file system storage, you will need a script to iterate through the ir_attachment table, extract the binary data, and write it to the correct file path based on the attachment's ID and model. This process can be time-consuming for large datasets, so it should be tested in staging to estimate the duration. Once the files are in place, you must update the Odoo configuration to point to the new file store location. Finally, run the Odoo upgrade script to apply any schema changes to the database. This step ensures that the database structure matches the target version's requirements.

Handling Orphaned and Corrupted Files

During the migration, you may encounter orphaned files, which are physical files in the file store that do not have a corresponding record in the ir_attachment table. These can occur due to previous failed deletions or manual file manipulations. You should identify and quarantine these files before the migration to prevent them from cluttering the new environment. Conversely, you may find database records that point to missing files. These are broken links that will cause errors when users try to access the attachments. You must decide how to handle these records: either delete the orphaned database records or flag them for manual review. It is not recommended to automatically delete records without business approval, as they may represent important historical data. Document all orphaned and broken records in a report for the business stakeholders to review. This transparency helps in understanding the data quality of the source system and sets expectations for the target system.

Validation and Integrity Checks

Validation is the most critical phase of the migration. You must verify that every attachment record in the database has a corresponding physical file and that the file content matches the original. A simple count of records is insufficient; you need to perform a checksum verification. Generate a list of all attachment IDs and their file paths from the source system, and do the same for the target system. Compare these lists to ensure no records are missing. For a sample of files, calculate the MD5 or SHA-256 hash of the source file and the target file to confirm that the binary data has not been corrupted during transfer. Additionally, test the user interface by logging into the staging environment and attempting to download, preview, and delete attachments. Test these actions for different user roles to ensure that security permissions are correctly applied. If you have custom modules that display attachments in specific views, test those views to ensure that the attachments are rendered correctly. Any discrepancies found during this phase must be resolved before proceeding to production.

Performance Testing

Attachment migration can significantly impact system performance, especially if the storage backend has changed. If you are moving from local storage to cloud storage, you must test the latency for downloading large files. Users may experience delays if the network connection to the cloud storage is slow. Perform load testing by simulating multiple users downloading attachments simultaneously. Monitor the CPU and memory usage of the Odoo server during this test to ensure that it can handle the load. If performance is degraded, consider implementing a caching layer or optimizing the network connection. Additionally, test the search functionality for attachments. If the target version uses a different indexing mechanism, search performance may vary. Ensure that users can quickly find the documents they need, as slow search can lead to user frustration and reduced adoption.

Cutover and Deployment Strategy

The cutover plan must minimize downtime and ensure a smooth transition to the new environment. Schedule the cutover during a period of low business activity, such as a weekend or holiday. Before the cutover, freeze all changes to the source system to prevent data divergence. Perform a final incremental backup of the source database and file store. Transfer this incremental data to the target environment and apply it to the staging database. This ensures that the target system has the most up-to-date data. Once the incremental data is applied, perform a final integrity check. If the check passes, switch the DNS or load balancer to point to the new environment. Communicate the cutover window to all users and provide a status page with real-time updates. Have a rollback plan ready in case of critical failures. The rollback plan should involve restoring the source database and file store from the pre-cutover backup and switching the DNS back to the old environment. This rollback must be tested in the staging environment to ensure that it can be executed within the acceptable downtime window.

Go/No-Go Criteria

  • All integrity checks passed with zero missing files
  • User acceptance testing completed with no critical defects
  • Performance benchmarks met for attachment download and search
  • Rollback plan tested and approved by the project team
  • Communication plan executed and user support team on standby

Post-Migration Stabilization

After the cutover, the system enters a stabilization period where you monitor for any issues that may not have been caught in testing. Monitor the Odoo logs for any errors related to attachment access, such as permission denied or file not found errors. Track user feedback and support tickets to identify any usability issues. If users report missing attachments, investigate immediately to determine if it is a data issue or a configuration issue. Have a dedicated team on standby to address any critical issues. During this period, avoid making any changes to the system unless they are necessary to fix critical bugs. Once the system has been stable for a defined period, such as one week, you can consider the migration complete. Decommission the old environment only after you have confirmed that all data has been successfully migrated and that the business has accepted the new system. Retain the old backups for a defined retention period, such as 30 days, in case any late-emerging issues are discovered.

Risk Management and Mitigation

Risk management is an ongoing process throughout the migration. The primary risks are data loss, downtime, and broken customizations. To mitigate data loss, always perform verified backups and test the restore process. To mitigate downtime, plan for a sufficient cutover window and have a rollback plan ready. To mitigate broken customizations, thoroughly test all custom modules in the staging environment and have a plan to disable or replace them if necessary. Additionally, consider the risk of user adoption. If the new document management interface is significantly different, users may struggle to find their documents. Provide training and documentation to help users adapt to the new system. Monitor user behavior to identify any areas of confusion and provide additional support as needed. By proactively managing these risks, you can ensure a successful migration that protects your business data and maintains operational continuity.

Conclusion

Migrating Odoo document management and attachment data is a complex task that requires careful planning, execution, and validation. By following a structured approach that includes version compatibility assessment, storage infrastructure preparation, rigorous data integrity checks, and a well-defined cutover strategy, you can minimize risks and ensure a successful migration. The key to success is attention to detail and a commitment to testing. Do not skip any validation steps, and always have a rollback plan ready. With the right preparation and execution, you can migrate your Odoo attachments safely and efficiently, ensuring that your business data remains secure and accessible in the new environment.

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

Frequently asked questions

Common questions on this topic. Talk to our team for anything specific to your business.

01Can Odoo attachments be migrated automatically during an upgrade?

In many cases, yes, if the storage backend remains the same and the file store is copied alongside the database. However, if you are changing storage backends (e.g., from database BLOBs to file system), manual transformation or scripting is required. Always verify in a staging environment.

02What is the safest way to store Odoo attachments during migration?

The safest way is to maintain a full backup of both the database and the file store. Use a verified backup solution that allows for point-in-time recovery. Ensure that the file store is copied using a method that preserves file permissions and timestamps.

03How do I verify that all Odoo files migrated correctly?

Perform a checksum verification (MD5 or SHA-256) on a sample of files and compare the file counts between the source and target systems. Additionally, test user access to attachments in the staging environment to ensure that files can be downloaded and previewed.

04Do custom Odoo modules affect attachment migration?

Yes, custom modules that interact with the ir_attachment model or override attachment behavior can break during migration. You must audit these modules for compatibility with the target version and test them thoroughly in a staging environment.

05What happens to orphaned attachments during an Odoo upgrade?

Orphaned attachments (files without database records) are typically not automatically deleted. They may remain in the file store, consuming space. You should identify and quarantine them before migration to prevent clutter in the new environment.

06How long does it take to migrate large Odoo attachment databases?

The time depends on the size of the data and the storage backend. Migrating from database BLOBs to file system storage can be time-consuming for large datasets. Test the process in a staging environment to estimate the duration and plan your cutover window accordingly.

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