Skip to Content
Menu
This question has been flagged
1 Reply
7255 Views

I'm using odoo in docker. I''m trying to setup backups, but all the info I've found is ancient.


I've seen many backing up "/var/lib/odoo" - but that is overkill as it backs up the app itself, not just user files.


Which are the user files that I need to backup?


I've seen some people mention "/usr/lib/python2.7/dist-packages/odoo/addons" as well - is that necessary, or outdated info?

Avatar
Discard
Best Answer

Odoo Backup

A simple docker container that run Odoo backups covering both Odoo files and PostgreSQL db based on docker-pg-backup. It then copy the backup files on GoogleDrive using drive cli.

Getting the image

There are various ways to get the image onto your system:

The preferred way (but using most bandwidth for the initial image) is to get our docker trusted build like this:

docker pull martel/odoo-backup:latest

To build the image yourself without apt-cacher (also consumes more bandwidth since deb packages need to be refetched each time you build) do:

docker build -t martel/odoo-backup .

If you do not wish to do a local checkout first then build directly from github.

git clone git://github.com/martel-innovate/odoo-backup

Run

To create a running container do:

docker run --name="backups"\
           --hostname="pg-backups" \
           --link=watchkeeper_db_1:db \
           -v ${PWD}/backup:/backup \
           -v ${PWD}/credentials.json:/var/credentials.json \
           -i -d martel/pg-backup

In this example I used a volume into which the actual backups will be stored.

Specifying environment

You can also use the following environment variables to pass a user name and password etc for the database connection.

  • PGUSER if not set, defaults to : docker
  • PGPASSWORD if not set, defaults to : docker
  • PGPORT if not set, defaults to : 5432
  • PGHOST if not set, defaults to : db
  • PGDATABASE if not set, defaults to : db
  • ODOO_FILES if not set, defaults to : 1 (it will backup also files in /var/lib/odoo)
  • DRIVE_DESTINATION if not set, defaults to : "" (no path, so it will not run a Drive backup)

Example usage:

docker run -e PGUSER=bob -e PGPASSWORD=secret -e ODOO_FILES=1
    -e DRIVE_DESTINATION=path -link db -i -d martel/pg-backup

One other environment variable you may like to set is a prefix for the database dumps.

  • DUMPPREFIX if not set, defaults to : PG

Example usage:

docker run -e DUMPPREFIX=foo -link db -i -d martel/pg-backup

Here is a more typical example using docker-composer:

For docker-compose.yml:

db:
  image: postgres:9.4
  environment:
    - POSTGRES_USER=docker
    - POSTGRES_PASS=docker

dbbackups:
  image: martel/pg-backup:latest
  hostname: pg-backups
  links:
    - db:db
  volumes:
    - ${PWD}/backup:/var/backup
    - ${PWD}/credentials.json:/var/credentials/credentials.json #TODO document how to create the file
  environment:
    - ODOO_FILES=0
    - DRIVE_DESTINATION=path
    - ODOO_FILES=0
    - DRIVE_DESTINATION=path
    - PGHOST=db
    - PGDB=db
    - PGUSER=docker
    - PGPASSWORD=docker
    - PGPORT=5432

Then run using:

docker-compose up -d dbbackup
Avatar
Discard
Author

Hi thanks for this option - I'm sure some will benefit from it.

But unfortunately it doesn't answer the question. We need to know which files to backup, not add more complexity.

Adding another app just to do backups is overkill.

If you know which files need to be backed up, please let me know, it would be appreciated.

Related Posts Replies Views Activity
0
Aug 24
564
9
Jul 24
87541
2
Sep 23
5700
9
Dec 22
59150
1
Sep 22
1141