In this tutorial we will walk you through the process of creating automatic daily backups of your Odoo databases. Odoo is the most popular open source ERP system written in Python and uses PostgreSQL as database back-end.

All the data of your Odoo instance is stored in a PostgreSQL database. Regularly backing up the database will protect you from potentially catastrophic data loss and it is absolutely critical for anyone and everyone who has an Odoo installation.

Odoo database management interface

The Odoo database management interface provides tools to backup, duplicate, delete, create and restore a database. Creating a backup using the database management interface is a no-brainer, simply open your browser and navigate to http://your_server_ip:8069/web/database/manager.

Depending on the database size, the backup may take some time before being ready.

Create a database backup from the command line

Now that we know how to create a backup through the Odoo database management interface, how can we use the same tool to create a backup from the command line? The answer is simple, we can use wget or curl. Both tools can send data with POST which we can use to pass the necessary variables to the Odoo database tool.

In the example bellow our Odoo Master Password is ADMIN_PASSWORD and we are creating a backup file back_up_filename.zip of a database named DB_NAME which will be saved in the backup_dir directory.

If you want to create a backup from a remote location instead of localhost you need to enter the URL to your Odoo instance. In this case it is recommended to use HTTPS because you do not want your password to be send through Internet as a plain text. You can find more information about to configure Odoo with nginx as a reverse-proxy here.

Advertisement

Setup Automatic Odoo Backup

To automate the backup process and backup our Odoo database at regular intervals we can create a cron job.

Let’s say that we want to backup our Odoo database each day at 01:30 am and keep the latest 7 backups.

We will create a simple bash script which you can name it as you want: