Restore backed up volume to another docker container (postgresql)

Viewed 31

I have backed postgres volume using this command:

sudo docker run --rm --volumes-from base -v $(pwd):/docker-volumes ubuntu tar cvf /docker-volumes/base_data.tar /var/lib/postgresql/data

It worked and then I transferred the .tar file to another server using scp. Now I need the postgres container in the new server to restore this data.

  • The new container is running and called base.
  • ~/docker-volumes/base_data.tar is where the backup file in the server.
  • /var/lib/posgresql/data is where this .tar must be unpacked inside the container.

I tried this:

sudo docker run --rm --volumes-from base -v $(pwd):/docker-volumes ubuntu bash -c "cd /var/lib/postgresql/data && tar xvf /docker-volumes/base_data.tar --strip 1"

I tried to tweek it in multiple ways but didnt work.

0 Answers
Related