Skip to content Skip to sidebar Skip to footer

Back Up Odoo Database Via Postgresql

Hi, this post are made just in case i forgot how to backup Odoo database via backend. Actually Odoo has a web interface to backup and restoring database by accessing your_ip:8069/web/database/manager through your browser. But in some case, On Premise server has an unknown error when restoring filestores and restoring all query itself. Most problems are the icons in main dashboard disappeared, and any medias and pdf files you've been uploaded isn't actually backed up properly. That's quite strange, since i also backing up filestores along with SQL query.

Odoo Backup & Restore Web Interface

So i came with another solution to restore it. There's two main act you should do to backing up your database. First, you need to back it up using query in postgresql to convert your database into a dump file. As I referring to the post in this link, there's four options to backup your database which every options has different pros and cons. But in this case I am using .dump format. After backing up the database, you need to backup filestore manually and copy it to somewhere else.

Backing Up Postgresql (Dumping)

  1. First, login to your server by using postgresql user.
  2. Then, know which database you are going to backup. To know it, you can access it by typing in psql. This will lead you to a postgresql CLI. After that, press \l to show all database in your postgres.
  3. After knowing the name of your database, type in \q to exit the CLI mode to go back to postgres user account.
  4. Later on, type in pg_dump --format=c yourDatabase >  yourDatabase.dump (replace yourDatabase with database name)
  5. Wait until the process is done, and you should see your .dump files in /var/lib/postgresql directory with the exact name as the query you type in.

Backing Up Filestores

Filestore is a place where media are kept by Odoo, including any images, pdfs, docs, and much more. When you are dumping a database via backend (postgresql) the filestore isn't backed up since we are only backing up queries in postgresql. So, to back it up you need to open /odoo/.local/share/odoo/filestore. The file location may be different but there is the default place. You may see multiple folder there, and if not try to type in find / -type d -name ".local. Each folder contains every files that your database has, which means every one of it may be different. That's why i tell you to know which database you are using first, so you don't get confused on it. Just copy the entire folder which has the same name as your database to another location, then set the permission of that copied folder to 777 and then you are good to go. Even with that, sometimes after replacing filestore to corespondent place it is still not showing the icons. So, i can tell you this tutorial are recommended for development and database testing purpose only. If you willing to do a proper backup for your server, please follow backup tutorial as i stated at the beginning of this post.