Mongorestore, from meteor production server to local
The easiest way that I found:
cd
in your project and executemeteor
command- in another terminal:
mongorestore -h 127.0.0.1 --port 3001 -d meteor dump/meteor
change 127.0.0.1
if your localhost has different ip address and 3001
to a port you have mongodb on (it is usually 3001
or 3002
, so try both), dump/meteor
is the path to a dump you created previously.
Also the easiest way to export local db:
cd
in your project and executemeteor
command- In another terminal:
mongodump -h 127.0.0.1 --port 3001 -d meteor
again, change localhost ip and port if needed. . As a result, the dump/meteor folder with db files will be created in the folder you cd
before running mongodump
.
Good luck.
To accomplish the opposite, sending local app data to production app, I wrote this little shell script. It has been useful while I am developing locally and just getting the demo synced for the client to view. Note it has --drop
at the end which will overwrite your production database, use with care!
It takes care of the client, pw, and server data from meteor mongo --url ...
which expires after 1 minute and is really annoying to try to copy-paste within that time.
#!/usr/bin/env bashmongodump -h 127.0.0.1:3001 -d meteor -o ~/www/APPNAME/server/dumpIN=`meteor mongo --url APPNAME.meteor.com`client=`echo $IN | awk -F'mongodb://' '{print $2}' | awk -F':' '{print $1}'`echo $clientpw=`echo $IN | awk -F':' '{print $3}' | awk -F'@' '{print $1}'`echo $pwserv=`echo $IN | awk -F'@' '{print $2}' | awk -F'/' '{print $1}'`echo $servmongorestore -u $client -h $serv -d APPNAME_meteor_com dump/meteor -p $pw --drop
This is what I do:
I. Create a mongo dump in the server
DATE=$(date +%m%d%y_%H.%M); mongodump --host localhost -d APPNAME -o /tmp/APPNAME_$DATE tar -cjvvf /tmp/APPNAME_$DATE.tar.bz2 /tmp/APPNAME_$DATE
II. Download the dump in the development machine and unpack in /tmp
scp root@$HOST:/tmp/APPNAME_$DATE.tar.bz2 /tmp/ cp /tmp/APPNAME_$DATE.tar.bz2 . mkdir -p /tmp/APPNAME_$DATE cd /tmp/APPNAME_$DATE tar -xjvf /tmp/APPNAME_$DATE.tar.bz2
III. Update local meteor development database
mongorestore --db meteor -h localhost --port 8082 --drop /tmp/APPNAME_$DATE/tmp/APPNAME_$DATE/APPNAME