Bash script to migrate Mongo databases to a new server with no hassle.
Official MongoDB documentation available here and here.
- Source and destination MongoDB server instances
- Admin rights to both MongoDB servers
- MongoDB with
mongodump
andmongorestore
tools installed
First, edit databases.txt
file to reflect the list of databases to be dumped.
nano databases.txt
chmod +x dump.sh && dump.sh
Second, download the files from old server using the scp
command.
scp -r <server>:<source_folder> <destination_folder>
scp -r x.x.x.x:/home/mongo/dump ./
Third, make sure the files have been downloaded to the dump
folder and launch the restore procedure on the new server.
chmod +x restore.sh && restore.sh
Bug reports and pull requests are welcome on GitHub at https://github.com/schopenhauer/migraine.
The module is available as open source under the terms of the MIT License.