I use the following setup:
Backup-Script /var/script/dump_db.sh
#!/bin/sh
hostname=`hostname`
##########################################
## OpenERP Backup
## Backup databases: openerpdb1, openerpdb2
##########################################
# Stop OpenERP Server
/etc/init.d/openerp-server stop
# Dump DBs
for db in openerpdb1 openerpdb2
do
date=`date +"%Y%m%d_%H%M%N"`
filename="/var/pgdump/${hostname}_${db}_${date}.sql"
pg_dump -E UTF-8 -p 5433 -F p -b -f $filename $db
gzip $filename
done
# Start OpenERP Server
/etc/init.d/openerp-server start
exit 0
Housekeeping script /var/script/housekeeping.sh (deletes backups which are older than 30 days)
#!/bin/sh
path=/var/pgdump
logfile=/var/log/$0
rm -f $logfile
for file in `find /var/pgdump/ -mtime +30 -type f -name *.sql.gz`
do
echo "deleting: " $file >> $logfile
rm $file
done
exit 0
Create daily cronjobs in /etc/crontab. The backup runs daily at 1am and the housekeeping job runs daily at 5am.
# m h dom mon dow user command
0 1 * * * postgres /var/scripts/dump_db.sh
0 5 * * * postgres /var/scripts/housekeeping.sh
来源:苏州远鼎官网
相关标签 TAG : odoo 数据库 定期 备份