Linux Bash Scripts -- Task failed

Hello Team - I have run all the steps correctly and created xfusioncorp_media.zip on appserver2 and on the backup server and verified the backup zip files on both the servers. I have verified password less login to backup server as well. The lab was closed immediately and says task failed with - ‘xfusioncorp_media.zip’ not found under ‘/backup’ on Backup Server. Could you please check my steps and advise ?

The production support team of xFusionCorp Industries is working on developing some bash scripts to automate different day to day tasks. One is to create a bash script for taking websites backup. They have a static website running on App Server 2 in Stratos Datacenter, and they need to create a bash script named media_backup.sh which should accomplish the following tasks. (Also remember to place the script under /scripts directory on App Server 2)

a. Create a zip archive named xfusioncorp_media.zip of /var/www/html/media directory.
b. Save the archive in /backup/ on App Server 2. This is a temporary storage, as backups from this location will be clean on weekly basis. Therefore, we also need to save this backup archive on Nautilus Backup Server.
c. Copy the created archive to Nautilus Backup Server server in /backup/ location.
d. Please make sure script won’t ask for password while copying the archive file. Additionally, the respective server user (for example, tonyin case of App Server 1) must be able to run it.

Steps I followed:

Login to stapp02 as Steve
cd /scripts
vi media_backup.sh
Inserted

#!/bin/bash

zip -r /backup/xfusioncorp_media.zip /var/www/html/media
scp /backup/xfusioncorp_media.zip clint@stbkp01:/backup/

Saved and exited

chmod +x media_backup.sh
setup password less login:
ssh-keygen
ssh-copy-id clint@stbkp01
Provide Clint password
tried logging into the machine, with: “ssh ‘clint@stbkp01’” successfully.
checked and made sure that the key(s) were added and it won’t asked for password.

Test on stapp02:
Ran the script media_backup.sh
Verifed files on backup server.

The lab was closed immediately and says task failed with - ‘xfusioncorp_media.zip’ not found under ‘/backup’ on Backup Server. Could you please check my steps and advise ?

I can only see this now.

Task Details

×

Uh! Oh! Looks like you might have missed something. The details are below. Don’t worry. No pressure! You will get another attempt at this task in the future.

  • ‘xfusioncorp_media.zip’ not found under ‘/backup’ on Backup Server

If you think you did it right and we checked it wrong, please post your comments at community.kodekloud.com

@Inderpreet @rahul456 @KodeKloud could you please look into this and advise ? Thank you.

@jsripad You create and ran the script though user root but it was supposed to run from sudo user i.e tony, steve etc. Also password-less access should have been done from sudo user.

Thank you @Inderpreet for the clarification.