This repository contains two Bash scripts to backup and restore an Odoo database along with its filestore.
- Automates PostgreSQL database and filestore backup
- Compresses backup with timestamped ZIP format
- Restores database and filestore with error handling
- Ensures safe rollback of previous filestore
- Supports automatic scheduled backups
This module is actively developed and open to improvements. Contributions, feedback, and suggestions are highly welcome! Remember: RTFM (Read The F*cking Manual) and KISS (Keep It Simple, Stupid!).
Run the script to create a backup of your Odoo database and filestore:
./odoo_backup.sh
- Creates a compressed ZIP backup of the database and filestore
- Saves backups under
/home/user/backups/
with the format:database_name_dd-mm-yy-hh-mm.zip
- Retains backups for 7 days, deleting older ones automatically
To schedule a daily backup at 2:00 AM, add this cron job:
crontab -e
Then add the following line:
0 2 * * * /path/to/odoo_backup.sh >> /var/log/odoo_backup.log 2>&1
This runs the backup script every night at 2:00 AM and logs output to /var/log/odoo_backup.log
.
Run the script with the backup ZIP file:
./odoo_restore.sh /path/to/backup.zip
- Extracts the backup into
/home/user/restore/backup_name/
- Restores the PostgreSQL database
- Moves the previous filestore (if exists) and restores the new one
- Skips filestore restoration if missing in backup
If the PostgreSQL user does not have a password, set it with:
sudo -u postgres psql
ALTER USER user WITH PASSWORD 'your_password';
\q
If a database with the same name exists, drop and recreate it before restoring:
sudo -u postgres dropdb database_name
sudo -u postgres createdb -O user database_name
For source-based Odoo installations, filestore is usually under:
~/.local/share/Odoo/filestore/database_name
For other installations (Docker, custom setups), verify the actual filestore path before restoring.
This project is released under the MIT/X License.