When I run below command , I'm getting the output as shown, How to fix this?
C:\Users\tadoori\Downloads\dump\m101>mongorestore dump
2016-10-21T13:54:09.883-0600 Failed: mongorestore target 'dump' invalid: GetFileAttributesEx dump: The system cannot find the file specified.
The argument you pass to mongodump is the dump path
As it seems you are already on the dump folder you can also specify the absolute path.
mongorestore C:\Users\tadoori\Downloads\dump
This will restore all dump folder contents (if the files are valid)
Related
I want to import some data in mongoDb database's collection. That collection already have some data and i want to import some more data into it. So for that i am using this command
mongorestore --drop -d local-db -c users /Documents/cwc/mongo-backups/Users.bson
but this command is always returning this error
Failed: mongorestore target '/Documents/cwc/mongo-backups/Users.bson' invalid: stat /Documents/cwc/mongo-backups/Users.bson: no such file or directory
How can i fix this?
From mongodocs:
Overwrite Files
"Mongodump overwrites output files if they exist in the backup data folder. Before running the mongodump command multiple times, either ensure that you no longer need the files in the output folder (the default is the dump/ folder) or rename the folders or files."
Hey guys,
I want to do a daily backup and sometimes even two backups a day. The Dump-filename gets named by the actual date. If I backup twice a day, the first backup gets overwritten due to same names.
Is there any way to tell mongodump to rename (in e.g. 5.9.2016(1)) the file if it already exists?
You can use the --out option of mongodump to specify the path where to dummp the data.
Create a script that run mongodump and give different name for your path, i.e. using a date:
mongodump --out /data/dump/090516/
Shell script example:
#!/bin/sh
DIR=`date +%m%d%y`
DEST=$DIR
mkdir $DEST
mongodump --out=/data/dump/$DEST
I have a bunch of mongo databases that I need to restore. I used mongodump to get the backup directories, which include the collections inside of them. Something like this:
|- mydir
|-- db1
|--- collection1
|--- collections2
|-- db2
|--- collection1
|--- collections2
I cd into mydir and do mongorestore and I get the following error:
2016-07-25T10:41:12.378-0400 using default 'dump' directory
2016-07-25T10:41:12.378-0400 Failed: can't create ActualPath object from path dump: stat dump: no such file or directory
Then I try to restore a specific database like this: mongorestore db2 and get the following errors:
2016-07-25T10:47:04.413-0400 building a list of dbs and collections to restore from db2 dir
2016-07-25T10:47:04.413-0400 don't know what to do with file "db2/collection1.bson", skipping...
2016-07-25T10:47:04.413-0400 don't know what to do with file "db2/collection1.metadata.json", skipping..."db2/collection2.bson", skipping...
2016-07-25T10:47:04.413-0400 don't know what to do with file "db2/collection2.metadata.json", skipping...
2016-07-25T10:47:04.414-0400 done
No matter what I do or what I try, I alternate between these two errors. And it's the same for any of the databases I use.
I tried using the --db flag, the -d parameter, setting the dump path as the third argument (mongorestore --db [db] [dump_path]). Everything I found around Stackoverflow. Nothing.
I'm stuck on this and I have no idea how to proceed.
EDIT
OS: Ubuntu 14.04
Installed MongoDB following this guide:
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/
mongorestore with no dump_path positional argument is expecting there to be a folder named dump in your current working directory. If the folder dump does not exist, you will get the "can't create ActualPath..." error.
So basically if you do not have a folder named dump, you will need to pass that positional argument. So from the parent directory of mydir run:
mongorestore mydir
If you want to use the --db option you will need to specify the dump path all the way down to the directory that contains the .bson files for that database or a specific .bson file.
So for example to restore all collections for db1:
mongorestore --db db1 ./db1
Or to just restore collection1:
mongorestore --db db1 ./db1/collection1.bson
I'm trying to restore a mongodump to a differently named database (which should be possible via --db <dbname> switch).
My working directory contains a single dump folder, which contains a single db dump.
However, when I try this command:
mongorestore --port xxxxx --db some_destination_db
I get the following error:
ERROR: ERROR: root directory must be a dump of a single database
ERROR: when specifying a db name with --db
I have no idea why I'm getting this, and can't find any help on google. Anyone have any ideas?
You need to include the path of the source db dump directory to restore from (as at MongoDB 2.6).
For example, if restoring from "twitter" to "some_destination_db" your command line would be similar to:
mongorestore --port xxxxx --db some_destination_db dump/twitter
May be your destination path contains some subfolders
I am trying to do a mongorestore command and I am not sure how to find the directory of where the data is.
The command is something like this:
mongorestore -v --db new_db_dump [path to the dump directory]
and I am not sure how to find where on my local computer the current dump is so I don't know what the [path to the dump directory] is supposed to be.
Any ideas for how to find it? I am on a mac.
Thanks!
By default, mongodump places its output in a sub-directory named "dump" in the current working directory. If you forgot where you were when you executed mongodump, try searching for "dump" in the finder, look at the resulting folders named "dump", and examine the contents. There will be a sub-directory inside "dump" for each of your databases.