This bash script will help you to backup Odoo database, set a password on the backup file and remove files older than 7 days. You’ll need curl and 7zip linux package to make it work. This example is backing up od11-01 and od11-02 databases. It’s not really optimized with the double compression.
BACKUP_DIR=/opt/backup ODOO_DATABASES="od11-01 od11-02" ADMIN_PASSWORD="ODOO_DATABASE_MANAGER_PASSORD" FILE_PASSWORD="ZIP_FILE_PASSWORD" TIMESTAMP=`date +%Y-%m-%d_%H-%M-%S` for DB in ${ODOO_DATABASES} do # create a backup curl -X POST \ -F "master_pwd=${ADMIN_PASSWORD}" \ -F "name=${DB}" \ -F "backup_format=zip" \ -o ${BACKUP_DIR}/${DB}/${DB}.${TIMESTAMP}.zip \ http://localhost:8069/web/database/backup 7z a -p${FILE_PASSWORD} -y ${BACKUP_DIR}/${DB}/${DB}.${TIMESTAMP}.zip.7z ${BACKUP_DIR}/${DB}/${DB}.${TIMESTAMP}.zip 7z t -p${FILE_PASSWORD} -y ${BACKUP_DIR}/${DB}/${DB}.${TIMESTAMP}.zip.7z rm -rf ${BACKUP_DIR}/${DB}/${DB}.${TIMESTAMP}.zip find ${BACKUP_DIR}/${DB} -type f -mtime +7 -name "${DB}.*.zip*" -delete donePOST HTML variables in this example is working for Odoo 9 version, for older or newer version of Odoo, those variables might be different. To get the right variables for your Odoo version, reach the database manager and get your field’s name from the code source of the backup form page.
Related Posts
-
Fail2ban Odoo 9 Authentication
Odoo 9 community doesn't come with autoban security. Fail2ban is an alternative to secure Odoo authentication. For more information concerning…
-
Create scheduled actions Odoo 9
Scheduled actions can be set by adding this code in your xml file. This exemple will call the function schedule_action…
-
How to search string in files Linux
Use this command bellow to find a pattern in the arborescence. [code lang="bash"] grep -rnw '/path/to/somewhere/' -e 'pattern' [/code] https://stackoverflow.com/questions/16956810/how-do-i-find-all-files-containing-specific-text-on-linux
-
Protect Odoo 11 database backup with a password
Database auto-backup backup process crashes with a database size > 200 MB and Odoo worker enabled. The module "Database auto-backup"…