DEV Community


Posted on


Take MySQL Database Backup From Jenkins

In this post, we will explain and practically show how you can configure MySQL database backup using Jenkins jobs. in easy words, you will automate the MySQL database backup process from Jenkins GUI.

  1. Log to Jenkins default URL and port:

If you want to install and setup Jenkins see this article

  1. Go to New items

  2. Give some Name and select FreeStyle project

  3. In the build section click on Add build step radio button and select Execute shell.

  4. Select boolean parameter for MySQL database host and database superuser password which is root password in MySQL database case.

  5. In this build part give the shell script name with full path and parameters like $HOST_IP & $Password

Shell Script

[root@master01 ~]# cat /opt/jenkins_scripts/




echo "starting mysql database full backup"

mysqldump -h $HOST_IP --all-databases --single-transaction --quick --lock-tables=false > /opt/jenkins_scripts/mysql_backup/full_backup_$(date +%F_%N).sql -u root -p$PASSWORD

echo "Backup has been done"

Latest comments (0)

Advice For Junior Developers

Advice from a career of 15+ years for new and beginner developers just getting started on their journey.