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.
- Log to Jenkins default URL and port: http://192.168.56.21:8080/
If you want to install and setup Jenkins see this article
Go to New items
Give some Name and select FreeStyle project
In the build section click on Add build step radio button and select Execute shell.
Select boolean parameter for MySQL database host and database superuser password which is root password in MySQL database case.
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/mysql_full_db_backup.sh
!/bin/bash
HOST_IP=$1
PASSWORD=$2
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"
Top comments (0)