Docker Community Forums

Share and learn in the Docker community.

How to move Images and Containers to new Server with historical data

docker

(Abhi110) #1

image :
docker save -o /root/bkp1/docker_image_bkp ccn/ccn-server:1.0.4
Container:
docker export cef0dff04e70 > /root/bkp1/container.tar
In new server :
docker load -i /root/pmmbkp1/docker_image_bkp
cat /root/bkp1/container.tar | docker import - ccdata
And I created and started it. But I am not able find the old data in the new server. How do I move the historical data along with the containers?

For example, I tired the below as well but no luck with copying the data to new server.

Backup
docker run --rm --volumes-from mm-data -v $(pwd):/backup percona/mm-server:1.0.4 tar cvf /backup/prometheus_backup.tar /opt/prometheus/data
docker run --rm --volumes-from mm-data -v $(pwd):/backup percona/mm-server:1.0.4 tar cvf /backup/consul_backup.tar /opt/consul-data
docker run --rm --volumes-from mm-data -v $(pwd):/backup percona/mm-server:1.0.4 tar cvf /backup/mysql_backup.tar /var/lib/mysql
Restore
docker run --rm --volumes-from mm-data -v $(pwd):/backup percona/mm-server:1.0.4 bash -c "cd /opt/prometheus/data && tar xvf /backup/prometheus_backup.tar --strip 1"
docker run --rm --volumes-from mm-data -v $(pwd):/backup percona/mm-server:1.0.4 bash -c "cd /opt/consul-data && tar xvf /backup/consul_backup.tar --strip 1"
docker run --rm --volumes-from mm-data -v $(pwd):/backup percona/mm-server:1.0.4 bash -c “cd /var/lib/mysql && tar xvf /backup/mysql_backup.tar --strip 1”