Knowledgebase

Question About Servers

How to Backup and Restore a Database in Odoo Print

  • 0

Odoo's database backup and restore feature offers several valuable benefits to users. By regularly creating backups, businesses can protect their critical data from loss, corruption, and system failures. Backups also facilitate disaster recovery, version control, and compliance requirements. They provide peace of mind, enable easy data migration, and simplify customization and configuration tasks. With a well-established backup schedule and proper storage, Odoo users can reduce downtime and quickly recover their data in case of any mishaps.

Here are the benefits of using the database backup and restore feature in Odoo:

  • Data Protection: Regularly creating backups of your Odoo database ensures that your business-critical information is protected from accidental deletion, corruption, or system malfunctions. In case of any data loss, you can quickly restore the backup to recover the lost information.

  • Disaster Recovery: The backup and restore feature is essential for disaster recovery scenarios, such as hardware failures, software bugs, cyber-attacks, or natural disasters. Having a recent backup allows you to recreate your database and resume operations with minimal downtime.

  • Version Control: Odoo provides versioning options for backups, allowing you to keep historical data snapshots. This feature is useful if you need to retrieve specific data from a specific point in time or analyze past trends.

  • Data Migration: Backups can be used to migrate your Odoo instance from one server or environment to another. Whether you're moving to a new server, upgrading Odoo versions, or setting up a test environment, having a backup simplifies the migration process.

  • Peace of Mind: Knowing that your data is safe and restorable gives you peace of mind, especially when dealing with sensitive business information and financial data. You can focus on your core tasks without worrying about data loss.

  • Compliance Requirements: In some industries, data backup and recovery are necessary to meet regulatory compliance requirements. Odoo's backup feature helps you fulfill such obligations and maintain data integrity.

  • Easy Recovery: Odoo's restore functionality allows you to recover your database with just a few clicks. This user-friendly process means you don't need advanced technical knowledge to perform data restoration.

  • Customization and Configuration: Regular backups allow you to experiment with customization, configuration, or module installation without the fear of damaging your live database. If something goes wrong during the changes, you can quickly revert to a previous working state.

  • Database Maintenance: Backups are useful for routine database maintenance tasks, such as cleaning up unwanted data or performing tests. If an issue arises during these operations, you can revert to the backup and start over.

  • Reducing Downtime: In case of a major issue that requires you to restore your database, having a recent backup can significantly reduce downtime, allowing you to get your system back up and running quickly.

How to Create a Database Backup

Step 1: Go to the database manager in your Odoo instance. To do this, use the following URL <odoo-url>/web/database/manager. Be sure to replace the "odoo-url' with the correct address and port that you use to access your Odoo instance. The database manager appears as shown below.

Step 2: Click on the "Backup" button as highlighted in the above screenshot. The dialog below will pop up. Enter the master password and select the backup format you wish to use. 

Odoo offers two backup formats for creating database backups:

  • ZIP (includes filestore): The ZIP format is the default and compressed backup option, reducing file size and making it suitable for most scenarios. By choosing the "zip" option, a zip file will be created, which includes the filestore, dump.sql, and manifest.json. The dump.sql file primarily holds all the (PostgreSQL backup) data, while the filestore contains static files like images and attachments stored on disks. The manifest.json file includes details such as the list of modules, Odoo version, database name, PostgreSQL version, and other relevant information.
  • Pg_dump custom format( without filestore): This format provides an uncompressed representation of the database, offering human-readable data and better control over large datasets or data migrations. Users can choose the format that best suits their specific needs and requirements.

Step 3: Click on the "Backup" button. Odoo will generate a backup for your database.

How to Restore a Database

The database restoration process in Odoo can be accomplished through either the Odoo interface or psql commands. For extensive databases, it is recommended to utilize psql commands. To initiate the restoration, a database backup is required. The restoration can be executed either through the front end or via the terminal.

From the Front End

Step 1: Using the front end, it is possible to restore the database. To do this, access the database manager at "odoo-url>/web/database/manager" and choose the "Restore Database" option as shown below.

Step 2: Click on the "Restore Database" button as highlighted in the above screenshot. The dialog below will pop up.

Step 3: Enter the master password, browse your directory for the .zip file, assign a name to the database, and then proceed by clicking the "Continue" button. 

In case you wish to exclude the filestore (images and attachments) during restoration, you can utilize the dump.sql file from the terminal to restore the database. Simply extract the database backup .zip file, which comprises filestore, manifest.json, and dump.sql.

From the Terminal

Execute the following commands in the terminal to perform the database restoration.

$sudo su postgres
$createdb -O [Owner] [database_name]
$pgrestore -d [database_name] [dumpfile_name].dump

Regularly creating backups of your Odoo database ensures that your business-critical information is protected from accidental deletion, corruption, or system malfunctions. In case of any data loss, you can quickly restore the backup to recover the lost information."

By consistently making backups of your Odoo database, you safeguard your vital business data from accidental deletion, corruption, or system issues.


Was this answer helpful?

« Back

Enterprise-Grade Hardware

  • Samsung
  • Juniper
  • Western Digital
  • Supermicro
  • LSI
  • Intel
  • R1Soft Backups
  • cPanel
  • MySQL
  • Parallels
  • HP Partner