Linux Bash Scripts error, backup automatically deleted from backup server causing task to failed

Hi,

This has happened twice with the same lab - Linux Bash Scripts

Both times, I created the script, and it worked as per the requirement. However as soon as I hit submit and confirm the task is done, the backup gets deleted from the backup server and it shows the task status as failed as it can’t find the backup.

'xfusioncorp_blog.zip' not found under '/backup' on Backup Server

Please check the attached snapshot.

  1. The app2 user is running the script, it takes the backup in the /backup of app2 first and then copies to /backup of backup server using ssh key

  1. This show the backup zip file is present in the /backup of backup server, but as soon as I submit the task, it gets deleted causing the task to fail.
    Screenshot from 2020-09-05 06-27-17

This has caused me to fail the same task twice. Please advise what is wrong with this.

Thanks,
Divya

@divyadivu Cleanup of the backup file is intentional so that validation can run your script from scratch to verify it it works fine. You ran and tested your script using sudo however you had to make sure it works fine without sudo . You must ensure that sudo users like tony, steve etc are able to run this script without sudo as if you are running the script using sudo its actually running as root.

Understood the mistake, thanks @Inderpreet