Odoo Backup and Restore

Backup Odoo Instance

Having a robust backup strategy is essential. With our Odoo Manager Tool, you can easily Backup and Restore your data. We offer the capability to take local backups independently, which you can then copy or upload offsite to enhance disaster recovery.

Follow Below Steps

Run Odoo Manager utilty as usual and select Backup Odoo ; this will trigger backup job and backup will be saved in /ODOO_BACKUP folder in tar and gzip format.

Run this command:

$sudo odoo_mgr
Odoo ERP Backup Database

Restore Odoo Instance

Follow Below Steps

Run Odoo Manager utilty as usual and select “Restore Odoo”; this will trigger restore job.

Run this command:

$sudo odoo_mgr
Odoo ERP Restore Database

You can use the Odoo Manager tool to take filesystem backup of both database and filestore/ sessions and restore flawlessly.

Benefits of a Strong Backup Strategy

  • Data Protection: Regular backups protect your data from loss due to accidental deletion, software bugs, or malicious attacks.

  • Business Continuity: In the event of a failure, quickly restoring your data ensures minimal disruption to your business operations.

  • Compliance: For industries with regulatory requirements, maintaining regular backups helps you stay compliant with data protection and retention policies.

  • Peace of Mind: Knowing that your data is regularly backed up and securely stored offsite gives you confidence in your disaster recovery plan.

By leveraging our Odoo Manager tool and implementing a comprehensive backup strategy, you can ensure that your critical business data is always protected, readily available, and secure.

Follow Below Steps:

  • Select the very first Setup 1 Option to set the time-zone to match with your location.

  • Select Setup 2 to configure your Odoo server, and now type a Website FQDN you registered.

Backup Strategies for Odoo

To ensure comprehensive coverage, let’s delve deeper into each of the backup strategies mentioned earlier.

1. Regular Automated Backups

Follow below Steps for Database Backups

PostgreSQL Backup with pg_dump:

pg_dump -U your_db_user -h your_db_host -F c your_db_name > /path/to/backup/your_db_name.backup |boxe|
  • -U: Specifies the database user.

  • -h: Specifies the database host.

  • -F: Specifies the custom format which is compressed.

  • your_db_name.backup: The name of the backup file.

  • Scheduling with Cron:shCopy code0 2 * * * /path/to/backup_script.sh

  • This cron job runs the backup script every day at 2 AM.

2. File System Backups

Backup Important Directories:

tar -czvf /path/to/backup/odoo_files_$(date +\%Y\%m\%d\%H\%M\%S).tar.gz /path/to/odoo/instance

Scheduling with Cron:

30 2 * * * /path/to/file_backup_script.sh This cron job runs the file backup script every day at 2:30 AM.

3. Incremental Backups

  • Using rsync For incremental File Backups:

    rsync -av –delete /path/to/odoo/instance /path/to/backup/directory
    -a: Archive mode.
    -v: Verbose output.
    --delete: Deletes files from the destination directory that no longer exist in the source.
  • Incremental Database Backups:

    Logical Replication: Set up logical replication in PostgreSQL to continuously replicate changes from the primary database to a standby database.

4. Offsite Backups

Using rclone for Cloud Storage: rclone sync /path/to/backup remote:backup remote: The name configured in rclone for the cloud storage provider.

4. Versioning

Retention Policy Implementation:

find /path/to/backup -type f -mtime +30 -exec rm {} \;

This command finds and deletes files older than 30 days.

5. Encryption

Encrypting Backups with GPG:

gpg --encrypt --recipient your_gpg_key /path/to/backup/your_db_name.backup

Secure Transfer using rsync over SSH:

rsync -avz -e ssh /path/to/backup user@remote_host:/path/to/remote/backup

6. Testing and Verification

Restoring a Test Database:

createdb -U your_db_user -h your_db_host test_db_name pg_restore -U your_db_user -h your_db_host -d test_db_name /path/to/backup/your_db_name.backup

Checksum Verification:

md5sum /path/to/backup/your_db_name.backup > /path/to/backup/your_db_name.backup.md5

To verify

md5sum -c /path/to/backup/your_db_name.backup.md5

7. Documentation

Creating Procedure Manuals:
  • Document each step involved in the backup and restore processes.

  • Include screenshots where applicable.

  • Provide clear instructions on how to handle errors.

Emergency Contacts:

  • Maintain a list of support contacts, including IT staff, service providers, and cloud storage providers.

8. Backup Tools and Software

Odoo Backup Modules

  • Database Auto-Backup:
    • This module allows you to configure automated backups from within the Odoo interface.

    • It provides options for setting backup frequency and remote storage.

PostgreSQL Tools

  • pg_dump and pg_restore: These tools are ideal for logical backups and restores.

  • pg_basebackup: Suitable for physical backups.

pg_basebackup -D /path/to/backup/directory -Fp -Xs -P -v
-D: Destination directory.
-Fp: Plain format.
-Xs: Stream the WAL (Write-Ahead Log) files.

See also

File Backup Tools

rsync: Ideal for both full and incremental file system backups.

Backup Software: There are many commercial backup products you can explore, some notable are…

  • Bacula: Enterprise-grade backup solution.

  • Duplicity: Encrypted, bandwidth-efficient backups.

  • Veeam: Comprehensive backup and recovery solution for virtual environments.

Sample Backup Script

 1#!/bin/bash
 2# Variables
 3 DB_USER="your_db_user"
 4 DB_HOST="your_db_host"
 5 DB_NAME="your_db_name"
 6 BACKUP_DIR="/path/to/backup/directory"
 7 TIMESTAMP=$(date +"%Y%m%d%H%M%S")
 8 BACKUP_FILE="${BACKUP_DIR}/odoo_backup_${TIMESTAMP}.sql"
 9 FILES_BACKUP="${BACKUP_DIR}/odoo_files_${TIMESTAMP}.tar.gz"
10 ODOO_DIR="/path/to/odoo/instance"
11 GPG_KEY="your_gpg_key"
12 REMOTE_USER="remote_user"
13 REMOTE_HOST="remote_host"
14 REMOTE_DIR="/path/to/remote/backup"
15
16 # Create backup directory if not exists
17 mkdir -p ${BACKUP_DIR}
18
19 # Backup PostgreSQL database
20 pg_dump -U ${DB_USER} -h ${DB_HOST} -F c ${DB_NAME} > ${BACKUP_FILE}
21
22 # Backup Odoo files
23 tar -czvf ${FILES_BACKUP} ${ODOO_DIR}
24
25 # Encrypt the backups
26 gpg --encrypt --recipient ${GPG_KEY} ${BACKUP_FILE}
27 gpg --encrypt --recipient ${GPG_KEY} ${FILES_BACKUP}
28
29 # Transfer to remote server
30 rsync -avz -e ssh ${BACKUP_FILE}.gpg ${FILES_BACKUP}.gpg ${REMOTE_USER}@${REMOTE_HOST}:${REMOTE_DIR}
31
32 # Clean up old backups
33 find ${BACKUP_DIR} -type f -mtime +30 -exec rm {} \;

Summary

Implementing these detailed backup strategies will help ensure your Odoo system’s data integrity and availability. Regular automated Full, Incremental and Offsite backups, encryption, and routine testing are crucial components of a robust backup plan. Thorough documentation and the use of reliable tools will further enhance your backup strategy.