Question:
Solution:
At first login to app server02
ssh steve@stapp02
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 clint@stbkp01:/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 clint@stbkp01
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.
Hi Shawon,
ReplyDeletewhere 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?
you need to run keygen command in appserver. It is better to run as sudo
DeleteHi Shawon, while running the script , i am getting permission denied error in the copy command, do i need to include sudo in the script?how should i deal with permission issues.do i need to run script as root user?Please suggest
ReplyDeletezip -r xfusioncorp_media.zip /var/www/html/beta
cp xfusioncorp_media.zip /backup/
scp -r /backup/xfusioncorp_media.zip clint@stbkp01:/backup
Please run as a root user. sudo su command will give you root access
Delete