Created
May 24, 2018 13:37
-
-
Save z010107/eb54b91f1ade6b2f8693ad0de228b649 to your computer and use it in GitHub Desktop.
Перенос баз mongo на новый сервер
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Для переноса создадим для начала папочку, в которую сложим дампы баз: | |
mkdir mongo | |
Создаем дамп первой базы: | |
mongodump -h localhost -u admin -p _password_ --authenticationDatabase admin -d _first_db_ -o mongo | |
Создаем дамп второй базы: | |
mongodump -h localhost -u admin -p _password_ --authenticationDatabase admin -d _second_db_ -o mongo | |
И так далее... Базы сохраняются в отдельных папках, создавая следуюзую стрктуру файлов: | |
mongo/_first_db_/files | |
mongo/_second_db_/files | |
Далее переносим файлы на новый сервер с помощью rsync: | |
rsync -avz -e ssh root@_old_server_ip_:/root/mongo/ /root/mongo/ | |
А теперь восстановим базы: | |
mongorestore -h localhost -u admin -p _password_ --authenticationDatabase admin -d _first_db_ mongo/_first_db_ | |
mongorestore -h localhost -u admin -p _password_ --authenticationDatabase admin -d _second_db_ mongo/_second_db_ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment