How To easily Setup Automatic Odoo database Backup?

How To easily Setup Automatic Odoo database Backup?

There are two ways you can backup your odoo database. One is manually make it thru Odoo interface. Another one is you can create a scheduled auto-backup thru cronjob. However, you need to have a root access on your application hosted server for the cronjob setup.

Odoo User Interface

http://myip:8069/web/database/manager

With the above URL, you can manually create the database backup with some clicks. Nothing is complicated. As for the master password, it should be the admin password. If you forgot and not aware of it, you can still find it from /odoo/conf/odoo-server.conf

For the Database Restore, delete the old one first, select the backup file from your local and input the correct database name. If you don’t know open odoo-server.conf this file to verify it.

Using WGET comand line

$ wget –post-data ‘master_pwd=adminPassword&name=daabaseName&backup_format=zip’ -O /home/desktop/username/desktop/databasefilename.zip http://myip:8069/web/database/manager

Setup a Schedule Cronjob

sudo nano /opt/script/backup-odoo.sh

#!/bin/bash
PATH=/usr/local/bin:/usr/local/sbin:~/bin:/usr/bin:/bin:/usr/sbin:/sbin

# variable
backupDir=/home/username/Desktop/Odoo-Backup
odooDatabase=myodoo
adminPassword=$pbkdf2

# make a default directory for backup
mkdir -p ${BACKUP_DIR}

# make a backup
curl -X POST \
  -F “master_pwd=${adminPassword}” \
  -F “name=${odooDatabase}” \
  -F “backup_format=zip” \
  -o ${backupDir}/${odooDatabase}.$(date +%F-%H-%M).zip \
  http://myip:8080/web/database/backup

# delete old backups if older than 30 days
find ${backupDir} -type f -mtime +30 -name “${odooDatabase}.*.zip” -delete

sudo chmod +x /opt/script/backup-odoo.sh
sudo crontab -e
0 */4 * * * /opt/script/backup-odoo.sh #backup every 4 hour

So, that’s all. If you have any problem, please feel free to let us know.

There are no reviews yet.

Leave a Reply

Your email address will not be published. Required fields are marked *



Start typing and press Enter to search