Skip to main content

Mongodb Export & Import

Export
Export လုပ္ဖုိ ့က ေအာက္က ကြန္မန္းကုိ Terminal ထဲမွာ ရိုက္ထည့္ရရင္ျပီ။ db_name ကိုေတာ့ ကုိယ္ထုတ္ခ်င္တဲ့ database name ကုိ ထည့္ရမွာပါ။ db_backup_folder_name ကေတာ့ export ထုတ္လုိက္တဲ့ ဖုိင္ေတြကုိ ထည့္ထားမယ့္ folder နာမည္ျဖစ္ပါတယ္။

mongodump -d db_name -o db_backup_folder_name

Import
Import လုပ္ဖုိ ့အတြက္က ေအာက္ကကုတ္ကုိ import.sh ဆိုပီး ဖိုင္ေလးေဆာက္ျပီး ထည့္ပါ။ db_name ကုိ ေဆာက္ခ်င္တဲ့ database name ေျပာင္းပါ။

ls -1 *.bson | sed 's/.bson$//' | while read col;
do
    mongorestore -d db_name $col.bson;
done

ျပီးရင္ေတာ့ Terminal ကေန ./import.sh ကုိ ရိိုက္ထည့္ရင္ ရသြားပါလိမ့္မယ္။
Permission Error တက္ရင္ sudo chmod -R a+rx import.sh ဆိုပီး terminal ကေန import.sh ရွိတဲ့ေနရာသြားပီး ရိုက္ေပးလုိက္ရင္ဆင္ေျပပါတယ္။

Thanks : Lornajane
source : http://www.lornajane.net/posts/2011/importing-and-exporting-mongodb-databases

Comments

Popular posts from this blog

Learning English Through Laughter : 3

Mr.Green went to Germany, because he had some work there.He came back last Monday, and his young wife met him at the airport. They walked to their car and passed a tall, pretty air-hostess. Mr. Green said to her , ' Goodbye, Miss Harris, ' and the air-hostess smiled and said, 'Good bye' too. Mrs. Green stopped and looked at the air-hostess .Then she said to her husband, 'How did you know her name?' 'That was easy,'answered Mr.Green. 'The names of the captain and all the screw were on a piece of paper in front of our seates.' 'What was the name of the captain?' Mrs. Green asked with a smile. Mr.Green launged and answered ,'I don't remember any of the other names.' 4/\/\@

Install Laravel installer in ubuntu

Terminal ဖြင့္ပီးေတာ့ ေအာက္က ကြန္မန္းထည့္ run ရပါတယ္။ composer global require "laravel/installer" ျပီးရင္ terminal ထဲမွာ laravel ဆိုပီး ရိုက္ၾကည့္ပါ။ေအာက္ကအတုိင္းေပၚရင္ေတာ့ အလုပ္လုပ္ပါျပီ။ တကယ္လုိ ့ laravel: command not found ဆိုပီးျပေနရင္ေတာ့ ေအာက္က Command ထပ္ရိုက္ထည့္ျပီး ျပန္စမ္းၾကည့္ပါ။ ဒါဆိုဆင္ေျပသြားမွာပါ။ export PATH="~/.composer/vendor/bin:$PATH"

Install node.js in ubuntu

ပ ထမဆံုး http://nodejs.org/ မွာ သြင္းမယ့္ ဖိုင္ကုိအရင္ေဒါင္းလိုက္ပါ။ ျပီးရင္  dependencie လိုအပ္တာေတြကုိ ေ အာက္က  ကြန္မန္းနဲ့ ႏွစ္ခုသြင္းပါ။ sudo apt-get install g++ curl libssl-dev apache2-utils sudo apt-get install git-core ျပီးရင္ေတာ့ ေအာက္က ကြန္မန္းနဲ့တဆင့္ျခင္းသြင္းရင္ ဆင္ေျပပါျပီ။ cd node { download ဆြဲထားတဲ့ဖိုင္ကုိ ျဖည္ျပီးေတာ့ အဲဒီဖိုင္ထဲဝင္ } ./configure make sudo make install ရမရစမ္းဖုိ့အတြက္က ေအာက္က tut ေလးစမ္းျပီးသိႏုိင္ပါတယ္။ ေအာက္က ကုတ္ေတြကုိ test.js ဆိုျပီးတခုခုေပးပီး တေနရာရာသိမ္းလုိက္ပါ။ var http = require ( 'http' ); http . createServer ( function ( req , res ) {   res . writeHead ( 200 , { 'Content-Type' : 'text/plain' });   res . end ( 'Hello Node.js\n' ); }). listen ( 8124 , "127.0.0.1" ); console . log ( 'Server running at http://127.0.0.1:8124/' ); သိမ္းျပီးရင္ Terminal ထဲကေန node test.js ဆိုျပီးေခၚရင္   Server running at http://127.0.0.1:8124/ ဆိုျပီးေပၚေ...