When backing up an instance of MongoDB, the mongodump command can be used with a variety of arguments to produce the desired output.
mongodump --host=mongodb.example.net --port=27017
The attached PowerShell script provides a complete process of managing MongoDB backups. Simply modify file paths as needed and set retention days if the script will be used to manage archives of backup files.
NOTE: The backup script can be automated by adding a 'Run PowerShell' step to a desired schedule in Identity Panel. The script attribute in the step can include the PowerShell script content or the file path of the script.
NOTE: The mongorestore command is also included at the bottom of the script.
--dryRun parameter runs mongorestore without actually importing any data, returning the mongorestore summary information. Use with
--verbose to produce more detailed summary information. Remove this parameter after executing mongorestore and reviewing the summary information to insure the desired result will be achieved.
Please sign in to leave a comment.