How to Fetch Multiple Credentials and Expose them in Environment using Jenkinsfile pipeline
Introduction In this post, we will see how to fetch multiple credentials and…
August 09, 2019
Assuming you have a mongodb database, and you want to take backup and restore it somewhere. Lets see how we can take backup and then restore it. And, you must have installed mongodb tools like
mongodump --db <source database name> --authenticationDatabase <source database name> -u <username of sourcedb> -p <password of source db>
It assumes that you have a running mongodb instance on port 27017.
mongodump --host <hostname>:<port> --db <source database name> --authenticationDatabase <source database name> -u <username> -p <password>
By default, the backup dump is stored in a new directory named dump under current directory.
If you want to change the directory where the backup dump should be saved, use -o option
mongodump --db <source database name> -o <my directory path>
# for remote
mongodump --host <hostname>:<port> --db <source database name> --authenticationDatabase <source database name> -u <username> -p <password> -o <my directory path>
Above commands will take backup of complete database. If you want to take backup of only few collections, use following command:
mongodump --db <source database> --collection <name of collection>
mongorestore --db <target database name> -h <hostname>:<port> -u <username of target database> -p <password of target database> --authenticationDatabase <target database> <path of my database e.g. dump/mydb>
Above command restore complete database. To restore only selected collection, use following:
mongorestore --db <target database> --collection <name of collection> <path of bson file under dump directory>
When you take backups, it creates binary json (bson) files in dump directory. Restore single collection command takes path of that bson file.
Sometimes, you have have database dump in json format. Use following command:
mongoimport --db <source database> --collection <name of collection> --file <path of json file> --jsonArray
mongoimport --db <database name> --collection <collection name> --type csv --headerline --file <path of csv file>
There are lot of command options while restoring. For example you don’t want to restore indexes. Use following command:
mongorestore --db <target database> --noIndexRestore -h <host>:<port> -u <username> -p <password> --authenticationDatabase <database name> <path of dump database>
Introduction In this post, we will see how to fetch multiple credentials and…
Introduction I have an automation script, that I want to run on different…
If your youtube video looks like:https://www.youtube.com/watch?v=g0kFl7sBdDQ…
Introduction In my previous article, I explained How to have set of fields and…
Introduction VS code is an excellent free IDE for maany types of programming…
Introduction In this post, we will discuss 3 different ways to import a…
Introduction In this post we will see following: How to schedule a job on cron…
Introduction There are some cases, where I need another git repository while…
Introduction In this post, we will see how to fetch multiple credentials and…
Introduction I have an automation script, that I want to run on different…
Introduction I had to write a CICD system for one of our project. I had to…
Introduction Java log4j has many ways to initialize and append the desired…