docker icon indicating copy to clipboard operation
docker copied to clipboard

Backup & Restore Pelias

Open umar18 opened this issue 5 years ago • 4 comments

Hello, Sorry if it sounds stupid !! I have successfully deployed Pelias on my Linux environment, now i want to setup another machine as backup. I don't want to setup the new machine from scratch and wait for another week. Can i make a backup of the existing docker and restore on the new machine ??

umar18 avatar Feb 06 '20 10:02 umar18

Hi @umar18, the way it works is that the docker containers themselves don't contain any state, so you can delete them and recreate them.

You'll need to make a copy of the files in your docker project directory such as .env, docker-compose.yml and pelias.json.

Then all the rest of the data is stored within a directory defined by the variable DATA_DIR (this depends on how you set it up on your computer):

pelias system env | grep DATA_DIR
DATA_DIR=/data/pelias/docker/projects/singapore

On my computer the data for this project is stored in /data/pelias/docker/projects/singapore and for you it'll be a different directory. This setting is defined in .env.

Within that directory you'll find all the data for elasticsearch and all other services listed in your docker-compose config:

ls -lah /data/pelias/docker/projects/singapore
total 0
drwxr-xr-x   9 peter  staff   288B Mar 19  2019 .
drwxr-xr-x   6 peter  staff   192B Oct 15 09:30 ..
drwxr-xr-x   3 peter  staff    96B Jan 10 16:31 elasticsearch
drwxr-xr-x  14 peter  staff   448B Mar 14  2019 interpolation
drwxr-xr-x   4 peter  staff   128B Mar 14  2019 openaddresses
drwxr-xr-x   3 peter  staff    96B Mar 14  2019 openstreetmap
drwxr-xr-x   4 peter  staff   128B Mar 14  2019 placeholder
drwxr-xr-x   3 peter  staff    96B Mar 14  2019 polylines
drwxr-xr-x   5 peter  staff   160B Mar 14  2019 whosonfirst

You can simply tar or zip or whatever that directory and copy it to another system.

Some things to be aware of are:

  • you might want to bring your containers down first with pelias compose down before archiving the data to ensure all the file handles are closed and data has been flushed to disk.
  • when you restore the directory on a new system, check that the .env file on the new system points to the correct location before doing a pelias compose up to bring all the containers up.
  • if you have different user accounts on the two systems (or differing UID or GID) then it's possible you might have permissions errors, you can probably resolve this with chown or chmod.

Hope that helps.

missinglink avatar Feb 06 '20 11:02 missinglink

Thanks @missinglink for the reply. For data i will do that but for the docker can i use docker commit and docker load commands ? Actually the problem is that i want to install Pelias completely offline (without internet)

umar18 avatar Feb 06 '20 11:02 umar18

Maybe https://docs.docker.com/engine/reference/commandline/save/ ?

missinglink avatar Feb 06 '20 13:02 missinglink

You can use commands for saving containers but you really don't need to, the containers are stateless, you can delete a container and spawn a new one and it'll still work.

You just need to find a way of getting the docker images on the host machine as you won't have access to docker pull when offline.

missinglink avatar Feb 06 '20 13:02 missinglink