MongoDB - Dump & Restore live db to local or vice versa

(0 comments)

MongoDB , A NoSQL database ,  handy commands :

        
# Run in live server 
sudo mongodump --host <host_url> --port 27017 --db <db_name> 
sudo tar -zcvf <compress_file_name_of_dump>.tar.gz dump
# Note down path like
/var/app/dump/<compress_file_name_of_dump>.tar.gz
scp <server_user>@<server_ip_address>:/var/app/dump/<compress_file_name_of_dump>.tar.gz <local_absolute_path_where_dump_will_download>
mongorestore --host localhost --db <db_name> --port 27017 <downloaded_dump_folder_absolute_path>
If you are not able to connect mongo server ...
 
sudo service mongodb stop
sudo rm /var/lib/mongodb/mongod.lock
sudo -u mongodb mongod -f /etc/mongodb.conf --repair
sudo service mongodb start
      
Currently unrated

Comments

There are currently no comments

New Comment

required

required (not published)

optional

required

captcha

required