There's more...

Experienced Odoo developers generally don't use the database management interface, and perform the operations from the command line. To initialize a new database with demo data, for instance, the following one-liner can be used:

$ createdb testdb && odoo-bin -d testdb

The additional bonus of this command line is that you can request the installation of addons while you are at it using, for instance, -i sale,purchase,stock (more on this in Chapter 2, Managing Odoo Server Instances).

To duplicate a database, stop the server and run the following commands:

$ createdb -T dbname newdbname
$ cd ~/.local/share/Odoo/filestore # adapt if you have changed the data_dir
$ cp -r dbname newdbname
$ cd -

Note that in the context of development, the file store is often omitted.

The use of createdb -T only works if there are no active sessions on the database, which means you have to shut down your Odoo server before duplicating the database from the command line.

To remove an instance, run the following command:

$ dropdb dbname
$ rm -rf ~/.local/share/Odoo/filestore/dbname

To create a backup (assuming that the PostgreSQL server is running locally), use the following command:

$ pg_dump -Fc -f dbname.dump dbname
$ tar cjf dbname.tgz dbname.dump ~/.local/share/Odoo/filestore/dbname

To restore the backup, run the following command:

$ tar xf dbname.tgz
$ pg_restore -C -d dbname dbname.dump
Caution!

If your Odoo instance uses a different user to connect to the database, you need to pass -U username so that the correct user is the owner of the restored database.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.167.114