Está en la página 1de 2

COMO REALIZAR UNA COPIA BASE DATOS DE OPENERP USANDO POSTGRESQL

Create a backup directory.. crear un directorio para el backup mkdir /home/openerp/backup/

Usando postgresql

Realizar el Backup de la Base de Datos


$ su openerp ingresar la contrasea del usuario en Ubuntu

Ejecutar el siguiente comando: pg_dump nombre_basedatos -Fp -U usuario_Ubuntu -h localhost -p 5432 > /home/openerp/nombredel_archivobackup #password contrasea del usuario de Ubuntu Ejemplo: pg_dump test1 -Fp -U openerp -h localhost -p 5432 > /home/openerp/dbbackup #password test1234

Restaurar La Base de Datos


Ejecutar el commando: $ su openerp createdb -U openerp -T template0 nombre_nuevaBaseDatos psql -f /home/openerp/ nombredel_archivobackup -d nombre_nuevaBaseDatos -h localhost -p 5432 q ejemplo: createdb -U openerp -T template0 test psql -f /home/openerp/dbbackup -d test -h localhost -p 5432 -q Esto ya lo probe en una virtual y si funciona

Si se quiere una copia automtica (esto no lo he implementado)


Automatic database backup For an automatic backup of your database you have to create a cronjob that runs daily at a certain time. You must have root rights to do this. If you want to use an new external harddisk you have to format and mount this HD first. Formatting of a harddisk sudo fdisk /dev/sdc #first create a partition. options to choose: n, p, primaire partitie 1 sudo mkfs.ext4 /dev/sdc1 #create the file system ext4 on the HD Create a mount directory sudo mkdir /backup sudo mount /dev/sdc1 /backup #mount your HD Automatic mount at reboot sudo blkid #gives you the UUID of the harddisk

sudo vi /etc/fstab Paste: UUID=5609af05-1cc8-4130-bf35-2d53e1eb7bb6 /backup ext4 defaults 0 0 #add this line at the end of the file df #this should give /dev/sdc1 /backup touch /backup/test #If its correct this file will be written to your HD It is better to do automatic backup locally and write the backups manually to your external harddisk and keep this harddisk in a save place. Create a backup directory cd /var/backups sudo mkdir openerp Create a crontab with a backup schedule sudo crontab -e paste: 0 3 * * * su postgres -c /usr/bin/pg_dump -U postgres test3 | gzip -c > /var/backups/openerp/dbbackup-$( date +\%d\%m-\%Y_\%H:\%M ).gz ; echo Database backup: $(date) >> /var/backups/openerp/dbbackup.log 0 4 * * 6 find /var/backups/openerp -xdev -ctime +30 -type f -exec rm \{\} \; sudo vi /var/log/syslog #See the cronjob logs

recurso: http://www.nedworkstut.com/?p=97

También podría gustarte