odoo恢复大数据库

admin 2019-9-17 6012

BACKUP FROM SOURCE:


1. Dump your database

sudo -u postgres pg_dump -U postgres -E UTF-8 -F p -b -C -f <<your_backup_filename.sql>> <<your_odoo_database_name>>

Replace <<your_backup_filename.sql>> with a name of your choice and <<your_odoo_database_name>> with the name of your Odoo database. Ensure the postgres user has right permissions on the target directory (consider using /tmp/ for example)

This will produce a complete SQL dump of your Odoo database including statements to create the database itself when restoring.


2. Archive your files

$ tar -cf <<your_directory>>/odoo-filestore.tar /var/lib/odoo/.local/share/Odoo/filestore/<<your_odoo_database_name>>/
$ tar -cf <<your_directory>>/odoo-local-addons.tar /var/lib/odoo/.local/share/Odoo/addons
$ tar -cf <<your_directory>>/odoo-global-addons.tar /usr/lib/python2.7/dist-packages/odoo/addons

Make an archive of:

* the file-store relative to your database (since Odoo 8, files are not stored in database but on the file system), replace <<your_odoo_database_name>> with the name of your Odoo database.

* the addons downloaded from the UI (local to your Odoo instance),

* the global addons available with all your Odoo instances.


RESTORE ON TARGET:

1. Stop Odoo

/etc/init.d/odoo stop


2. Expend file archives

Remove folder /var/lib/odoo/.local/share/Odoo/filestore/<<your_odoo_database_name>>/

Remove folder /var/lib/odoo/.local/share/Odoo/addons

Remove folder /usr/lib/python2.7/dist-packages/odoo/addons

$ tar xvf <<archive-name.tar>>

Expend all 3 archives and move directories on the target machine to their respective locations .


3. Restore database

$ sudo -u postgres psql
postgres=# DROP DATABASE <<your_odoo_database_name>>
postgres=# \i <<path_to/your_backup_filename.sql>>
postgres=# \q

Connect to your PostgreSQL server, drop the current database and import your database dump. This file will create the database and make it owned by user odoo.


4. Update your filestore

$ sudo -u odoo odoo -c /etc/odoo/odoo.conf -u all

Start Odoo from command line as user odoo and force update (-u all option), then browse to your Odoo server from http://<<your_odoo_url>>:<<your_odoo_port>>. Example : http://127.0.0.1:8069.

The first request will require a little moment to run: Odoo proceeds to an complete update.

When done, type CTRL+C to stop Odoo.

$ /etc/init.d/odoo start

Restart odoo as a daemon. Done. \o/



=============================

其他参考文章:

https://zeroheure.info/how-to-restore-an-odoo-backup-quick-help/

https://linuxize.com/post/how-to-setup-automatic-odoo-backup/

https://github.com/odoo/odoo/issues/8170

https://www.odoo.com/fr_FR/forum/aide-1/question/odoo-8-backup-and-restore-command-lines-113791

https://linuxhostsupport.com/blog/how-to-migrate-odoo-from-one-server-to-another/

https://www.vultr.com/docs/how-to-backup-and-restore-postgresql-databases-on-ubuntu-16-04



最新回复 (0)
返回