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:

#!/bin/bash
zip -r /backup/xfusioncorp_beta.zip /var/www/html/beta
scp /backup/xfusioncorp_beta.zip clint@stbkp01:/backup/

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

3 Likes

@akshayyw @Tej-Singh-Rana @Inderpreet and others,

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

Steps followed are as below:

  1. created script in stapp01
    2

  2. on stapp01
    ssh-keygen
    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.

Regards,
Yogendra

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 @Tej-Singh-Rana

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

Thanks,
Yogendra

Hi @Tej-Singh-Rana

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

Regards,
Yogendra

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.
thanks

@Inderpreet @Ayman

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