Jenkins database backup job

Use this category to discuss the doubts and questions about the Jenkins course on KodeKloud


Hello can you someone can help with this task

Hi @Martoni

Thanks for your feedback with screenshot, please share the Jenkins level and task name, I’ll check it.

Yes I didn’t put that much info.
the Jenkins level is 2 task 4:
I install plug in publish over SSH
Put the details on DB server in the general settings
create e key in DB server and copy it on backup server
I use this exec command:
mysqldump -u kodekloud_roy -pasdfgdsd kodekloud_db01 > db_$(date +%F).sql
scp db_$(date +%F).sql clint@stbkp01:/home/clint/db_backups/
rm -f db_$(date +%F).sql

I used this script:

#!/bin/bash
echo “Starting backup” >&2
/usr/bin/mysqldump -u kodekloud_roy -pasdfgdsd kodekloud_db01 > /home/peter/db_$(date +%F).sql 2>> /home/peter/backup.log
if [ -f /home/peter/db_$(date +%F).sql ] && [ -s /home/peter/db_$(date +%F).sql ]; then
echo “Dump created, transferring…” >&2
scp /home/peter/db_$(date +%F).sql clint@stbkp01:/home/clint/db_backups/ 2>> /home/peter/backup.log
rm -f /home/peter/db_$(date +%F).sql
echo “Transfer complete” >&2
else
echo “Dump failed or file empty” >&2
cat /home/peter/backup.log >&2
exit 1
fi

on Jenkins output still says no 0 transfer files but everything else is ok.

on the checking its pass successfully