首页 > 代码库 > Odoo Auto Backup Database And Set Linux task schedualer

Odoo Auto Backup Database And Set Linux task schedualer

First ,Write Database Backup Script:

pg_dump -Fc yourdatabasename > /home/yourfilepath/yourdatabasename$(data+%Y-%m-%d).dump

Save it as a file name dump.sh

 

su root user,and set schedualer job:

crontab -e

set every day 3:00 am auto backup database:

00 3 * * * su - postgres /home/dump.sh >> /var/log/cron.pgsql.log 2>&1

if needed, set auto delete database file 10days before:

00 5 * * * find /home/db_backup -name *.dump -mtime +10 -exec rm "{}" \;

 

at last,restart cron service:

sudo service cron restart

 

Odoo Auto Backup Database And Set Linux task schedualer