Linux Bash Scripts Kodekloud

 


Question:

Solution:

At first login to app server02

ssh [email protected] 

Then go to scripts folder and create media_backup.sh

vi media_backup.sh

Next write this commands and save it

#!/bin/bash
zip -r /backup/xfusioncorp_media.zip /var/www/html/media
scp /backup/xfusioncorp_media.zip [email protected]:/backup/

Then create a keygen and copy the key to backup server so that bash script will not require any password

ssh-keygen

ssh-copy-id [email protected]

Finally go to scripts folder and run the bash scripts by this command

sh  media_backup.sh

Now you can check the backup folder for the zip file on both app02 and backup server. If you find the zip file then it should be done.

Share on Google Plus

About Ashadullah Shawon

I am Ashadullah Shawon. I am a Software Engineer. I studied Computer Science and Engineering (CSE) at RUET. I Like To Share Knowledge. Learn More: Click Here
    Blogger Comment
    Facebook Comment

1 comments:

  1. Hi Shawon,
    where am I supposed to run keygen commands?
    inside the script? or in application server? or backup server?
    also, do I need to run as sudo?

    ReplyDelete