Linux Bash Scripts

You don’t need to add yum install zip unzip just remove that as zip binary is already available .
Just add this lines in script:

zip -r /backup/ /var/www/html/beta
scp /backup/ clint@stbkp01:/backup/

And do $ ssh-keygen and $ssh-copy-id clint@stbkp01 manually
Add name of the files as per task


@akshayyw @player001 @Inderpreet and others,

task failed with below error though i m sure about my steps.

Steps followed are as below:

  1. created script in stapp01

  2. on stapp01
    ssh-copy-id clint@stbkp01
    was able to login to stbkp01 from stapp01 without any password

  3. when ran script can see zip file in both stapp01 /backup folder as well as stbkp01 /backup folder.

Please assist me in getting it right.
Thanks in adavce.


Hello, @yogendra
I think you have to perform this task from respective sudo user of the app server. You are in the app server 1 so should be tony not root.

Hi @player001

Agree with your findings. Let me try once it is reassigned.


Hi @player001

you were right i got succeeded now by doing it as respective sudo users. Thanks much.


Solution for the beginners : Linux Bash Scripts Kodekloud

hey Akshay.
when you say.
do $ ssh-keygen and $ssh-copy-id clint@stbkp01 manually
where should I perform this task?
on backup server? or on app server? or inside the bash script.

@Inderpreet @KodeKloud

Can you please let me know what went wrong in failing this task? I can check the backup folder for the zip file on both app03 and backup server.

Screenshot 2020-10-19 at 1.30.25 PM

from app server , coz you have to get generate keygen of stbkp01 for app server