Experienced Odoo developers generally don't use the database management interface and perform 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 add-ons while you are 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.
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
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.