Reputation: 17876
I understand I can dump data with this common
mongodump --db mydb
This command will dump all mydb collections data to ./dump/mydb. But I would like to dump data to another directory I named (say /home/user/mydb)
I have tried with --dbpath and --directoryperdb options and it seems not what I want
Is there a way to do this?
./mongodump --help
Export MongoDB data to BSON files.
options:
--help produce help message
-v [ --verbose ] be more verbose (include multiple times for more
verbosity e.g. -vvvvv)
--version print the program's version and exit
-h [ --host ] arg mongo host to connect to ( <set name>/s1,s2 for
sets)
--port arg server port. Can also use --host hostname:port
--ipv6 enable IPv6 support (disabled by default)
-u [ --username ] arg username
-p [ --password ] arg password
--dbpath arg directly access mongod database files in the given
path, instead of connecting to a mongod server -
needs to lock the data directory, so cannot be used
if a mongod is currently accessing the same path
--directoryperdb if dbpath specified, each db is in a separate
directory
--journal enable journaling
-d [ --db ] arg database to use
-c [ --collection ] arg collection to use (some commands)
-o [ --out ] arg (=dump) output directory or "-" for stdout
-q [ --query ] arg json query
--oplog Use oplog for point-in-time snapshotting
--repair try to recover a crashed database
--forceTableScan force a table scan (do not use $snapshot)
Upvotes: 0
Views: 1556
Reputation: 21692
You want the -o option:
-o [ --out ] arg (=dump) output directory or "-" for stdout
That will let you specify where the output goes.
Upvotes: 2