Hi All,
Not a question, but a feedback after I encountered issues restoring an instance of Odoo on another machine.
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/
Thanks for the write up. For the next time, it would be better to create it as a Q&A, like here: https://www.odoo.com/forum/help-1/question/ubuntu-16-04-how-to-install-sass-for-odoo-123090 .
What I'm looking for since a long time: how is it possible to restore a database without stopping Odoo?