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.taris where the backup file in the server./var/lib/posgresql/datais where this.tarmust 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.