Taking scheduled backup of mysql using Jenkins and powershell script

Jenkins pipeline as code to take database backup of mysql at scheduled time

GENERATE GITHUB TOKEN

Go to developer settings and generate Personal access token.

Settings >> Developer settings >> Personal access token

UPDATE TOKEN UNDER JENKINS

Go to credential manager under jenkins

Under credential manager create token based credential with name git-cred-token under password put the credential we have just generated , click on save.

PIPELINE CREATION UNDER JENKINS

Now come to Jenkins choose New Item then choose project type as Pipeline.

Under Pipeline configuration page and under Pipeline tab choose options as below

SCM :- git
Repository URL GitHub – devops81/dbbackupscript can fork this repository

Credentials :- Choose the credential git-cred-token which we generated above

Click on save it should complete the job creation.

Come back to the project page and click on Build Now it should ask for parameters as database name whose backup required to be taken.

Choose the database whose backup required to be taken click on build now option internally it should call the Jenkinsfile under the GITHUB repository.

Once the pipeline is success it should be shown as below.

Database backup should be created at designated location.

Leave a Reply