restore all
mongorestore --host=<host> --port=<port> --username=<username> --authenticationDatabase=<authenticationdatabase> --nsInclude "*.*" <path to dump>
backup all
mongodump --ssl --host <domain> --port <port> -p <password> --authenticationDatabase <authenticationdatabase> -u <username> -p <password> --out <dir path>
If you want to backup databases use:
mongodump --ssl --host <domain> --port <port> -p <password> --authenticationDatabase <authenticationdatabase> -u <username> -p <password> --out <dir path>
if the database has ssl enabled include the --ssl
flag
if you don't include the --out
mongodump
will create a "/dump" directory.
Inside the dump or specified backup directory you'll find directories with the names of your databases, inside each of them, you'll find the backups files, for each collection you'll find a ".bson" and a ".metadata.json"
To restore all the databases use:
mongorestore --ssl --host=<host> --port=<port> --username=<username> --authenticationDatabase=<authenticationdatabase> --nsInclude "*.*" <path to dump>
Again if the database has ssl enabled include the --ssl
flag if not just remove it.
the --nsInclude
flag tell mongorestore
which databases or collections you want to restore.
Examples:
--nsInclude=test.users
this will backup the users collection of the database test, and therefore will fail if the path to the dump is anything but the path to the users.bson of that particula database
To include all the database and all the collections use --nsInclude=*.*
or --nsInclude *.*
then define the path to all the collection directories of your backup
/dump
, i did not specify the directory and it restored the db perfectly. – Earthward