mongo database backup docker, the import

1. Objective: imported from the server to a backup database mongo container vessel b to the server's mongo

Step 2: 1) a container into the server: docker exec -it wedia-test-mongo-svr2 / bin / bash (container name: wedia-test-mongo-svr2)

              2) perform a backup: mongodump -h 127.0.0.1 --port 27017 -u = root -p = password -d test -o / dump (-d specified database, test: back up the database name, -o backup to the specified directory)

              3) packaged in containers backup file: tar -zcvf test.tar.gz / dump / test

              4) back to the host computer, copy the files out of the container: docker cp wedia-test-mongo-svr2: /dump/test.tar.gz / home (vessel name: wedia-test-mongo-svr2)

              5) downloaded to the local sz filename (yum install lrzsz)

              6) b uploaded into the server rz, extract the tar -zxvf /home/test.tar.gz 

              7) to the container: docker cp / home / dump / wedia_test hejuan: / home

              8) into the container to restore data: mongorestore -h 127.0.0.1 --port 27017 -d wedia_test / home / wedia_test

Guess you like

Origin www.cnblogs.com/atester/p/11453531.html