Day 74: Jenkins Database Backup Job 100 Days of DevOps scp of sql file not working

0 file transfer happen
steps followed:
https://medium.com/@yashvikothari/day-74-jenkins-database-backup-job-79d9c8604637

Try referring to the solution recorded here, and see if it helps.

Sharing the steps you took to clear the task in a site behind a paywall wont help.
you can share the steps either as screenshots or in a code-block using </> button on top of editor ribbon.


Day 74: Jenkins Database Backup Job

100 Days of DevOps

There is a requirement to create a Jenkins job to automate the database backup. Below you can find more details to accomplish this task:

Click on the Jenkins button on the top bar to access the Jenkins UI. Login using username admin and password Adm!n321.

  1. Create a Jenkins job named database-backup.
  2. Configure it to take a database dump of the kodekloud_db01 database present on the App server (stapp01) in Stratos Datacenter, the database user is kodekloud_roy and password is asdfgdsd.
  3. The dump should be named in db_$(date +%F).sql format, where date +%F is the current date.
  4. Copy the db_$(date +%F).sql dump to the Storage server (ststor01) under location /home/natasha/db_backups.
  5. Further, schedule this job to run periodically at */10 * * * * (please use this exact schedule format).

Note:

  1. You might need to install some plugins and restart Jenkins service. So, we recommend clicking on Restart Jenkins when installation is complete and no jobs are running on plugin installation/update page i.e update centre. Also, Jenkins UI sometimes gets stuck when Jenkins service restarts in the back end. In this case please make sure to refresh the UI page.
  2. Please make sure to define you cron expression like this */10 * * * * (this is just an example to run job every 10 minutes).
  3. For these kind of scenarios requiring changes to be done in a web UI, please take screenshots so that you can share it with us for review in case your task is marked incomplete. You may also consider using a screen recording software such as loom.com to record and share your work.

0. Login to Jenkins

Click Jenkins on the top bar.

Login:

  • Username: admin
  • Password: Adm!n321


1. Update/install plugins

Go to:

Manage Jenkins → Plugins

Install these if they are not already installed:

  • SSH Credentials
  • Publish Over SSH

After installation, select:

Restart Jenkins when installation is complete and no jobs are running

If the UI gets stuck after restart, refresh the browser.


2. Configure SSH server

Go to:

Manage Jenkins → System

Find Publish over SSH.

Add an SSH server.

Use:

  • Name: ststor01
  • Hostname: ststor01
  • Username: natasha
  • Remote Directory: /home/natasha/db_backups

Configure the SSH authentication using the credentials provided by the lab.

Click:

Test Configuration

You want to see a successful connection.

Then click Apply and Save.


3. Create Jenkins job

From Jenkins dashboard:

New Item

Enter:

database-backup

Select:

Freestyle project

Click OK.


4. Configure schedule

In the job configuration, find Build Triggers.

Check:

Build periodically

Enter exactly:

*/10 * * * *


5. Add build step

Go to:

Build → Add build step

Select:

Send files or execute commands over SSH

Select your configured SSH server:

ststor01

For Exec command, use:

mkdir -p /tmp/db-backup

mysqldump -h stapp01 -u kodekloud_roy -p’asdfgdsd’ kodekloud_db01 > /tmp/db-backup/db_$(date +%F).sql

ls -la /tmp/db-backup

scp -o StrictHostKeyChecking=no /tmp/db-backup/db_$(date +%F).sql natasha@ststor01:/home/natasha/db_backups/

rm -rf /tmp/db-backup

Important

Because your task specifically says the database is on stapp01, the important part is:

mysqldump -h stapp01 -u kodekloud_roy -p’asdfgdsd’ kodekloud_db01

The output filename will automatically be:

db_2026-08-26.sql

on August 26, 2026.


6. Save and build

Click:

Save

Then:

Build Now

Open:

Build #1 → Console Output

You should see the dump being created and transferred.


7. Verify on storage server

If you have terminal access, check:

ssh natasha@ststor01

Then:

ls -lh /home/natasha/db_backups/

You should see:

db_2026-08-26.sql


Final Jenkins configuration

Your job should have:

Job Name:
database-backup

Build Trigger:
*/10 * * * *

Database:
kodekloud_db01

Database User:
kodekloud_roy

Database Password:
asdfgdsd

Database Server:
stapp01

Backup Server:
ststor01

Backup Location:
/home/natasha/db_backups

Filename:
db_$(date +%F).sql

Take screenshots of:

  1. Job configuration showing */10 * * * *
  2. SSH configuration
  3. Execute command
  4. Successful Console Output

please help @Santosh_KodeKloud shared stesps followed

I just tried it, and the issue is that /home/natasha/db-backups does not exist on the Storage Server. You need to create it in the exec. Then scp.

I have a more elaborate exec, using sshpass (refer to screenshots)