- Odoo 11 Development Cookbook(Second Edition)
- Holger Brunn Alexandre Fayolle
- 191字
- 2021-06-25 22:48:34
Backups
The recipe does not cover backups. At the very least, you should have the cron task on the server running a daily backup. A simple and basic solution is to edit the crontab file as root by running crontab -e and to add the following lines:
@daily su postgres -c pg_dumpall | gzip >\
/backups/postgresql-$(date +%u).dump.gz @daily tar czf /backups/odoo-filestore-$(date +%u).tgz \
/home/odoo/odoo-prod/project/filestore
Don't forget to create the /backups directory. The backup files should not be stored on the same hard disk, and ideally, they would be mirrored on a server in a different physical location. Check these backups on a regular basis; having backups that you can't restore when you need them is useless.
The proposed solution is to keep daily backups of the last 7 days, which means you will lose one day of work in case of a problem. There are more advanced solutions available for PostgreSQL that allow point-in-time recovery. You will find more information about this in the book PostgreSQL 9 Admin Cookbook, Packt Publishing. Similarly, there are many Linux tools, such as duplicity (http://duplicity.nongnu.org/), which you can use for file backups allowing easy management.