Please can someone guide me where I did wrong. My TASK status says failed:
Failure Details:
- ‘xfusioncorp_news.zip’ not found under ‘/backup’ on Backup Ser
Question:
QQ: he 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 1
in Stratos Datacenter, and they need to create a bash script named news_backup.sh
which should accomplish the following tasks. (Also remember to place the script under
/scripts directory on App Server 1)
a. Create a zip archive named xfusioncorp_news.zip of /var/www/html/news directory.
b. Save the archive in /backup/ on App Server 1. 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, tony in case of App Server 1) must be able to run it.
Ans:
[root@stapp01 tony]# cd /scripts
[root@stapp01 scripts]# ls
[root@stapp01 scripts]# vi news_backup.sh
[root@stapp01 scripts]# cat news_backup.sh
#!zip/bin/bash
zip -r /backup/xfusioncorp_news.zip /var/www/html/news
scp /backup/xfusioncorp_news.zip clint@ 172.16.238.16:/backup
[root@stapp01 scripts]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory ‘/root/.ssh’.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:wlFpjNXprMRUm4/C5b8Ubopw2dDV24I/8zu/LJn21Ns root@ stapp01.stratos.xfusioncorp.com
The key’s randomart image is:
±–[RSA 2048]----+
| +o+… |
| …= oo . |
| .+ o+ . . |
| . oo+o+ . o |
| o.S.+ + o .|
| …= o o …|
| . o . = *…|
| o . + o=o|
| . . o oE|
±—[SHA256]-----+
[root@stapp01 scripts]# ssh-copy-id clint@ 172.16.238.16
/bin/ssh-copy-id: INFO: Source of key(s) to be installed: “/root/.ssh/id_rsa.pub”
The authenticity of host ‘172.16.238.16 (172.16.238.16)’ can’t be established.
ECDSA key fingerprint is SHA256:bOe2OkMlMAaZGXuZJ73VzMiuF4Vkko6eHTyhwVG+/Uw.
ECDSA key fingerprint is MD5:70:9f:87:7b:dd:f2:fc:7b:6f:1d:22:7c:c8:b2:9d:03.
Are you sure you want to continue connecting (yes/no)? yes
/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed – if you are prompted now it is to install the new keys
clint@ 172.16.238.16’s password:
Permission denied, please try again.
clint@ 172.16.238.16’s password:
Number of key(s) added: 1
Now try logging into the machine, with: “ssh ‘clint@ 172.16.238.16’”
and check to make sure that only the key(s) you wanted were added.
[root@stapp01 scripts]# ssh
usage: ssh [-1246AaCfGgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]
[-D [bind_address:]port] [-E log_file] [-e escape_char]
[-F configfile] [-I pkcs11] [-i identity_file]
[-J [user@]host[:port]] [-L address] [-l login_name] [-m mac_spec]
[-O ctl_cmd] [-o option] [-p port] [-Q query_option] [-R address]
[-S ctl_path] [-W host:port] [-w local_tun[:remote_tun]]
[user@]hostname [command]
[root@stapp01 scripts]# ssh clint@ 172.16.238.16
[clint@stbkp01 ~]$
[clint@stbkp01 ~]$
[clint@stbkp01 ~]$
[clint@stbkp01 ~]$ cd backup
-bash: cd: backup: No such file or directory
[clint@stbkp01 ~]$ cd /backup
[clint@stbkp01 backup]$ ls
[clint@stbkp01 backup]$ ls
[clint@stbkp01 backup]$ ls
[clint@stbkp01 backup]$ ls
[clint@stbkp01 backup]$
[clint@stbkp01 backup]$ ls
[clint@stbkp01 backup]$ logout
Connection to 172.16.238.16 closed.
[root@stapp01 scripts]# cd
[root@stapp01 ~]#
[root@stapp01 ~]#
[root@stapp01 ~]#
[root@stapp01 ~]# cd /scripts/
[root@stapp01 scripts]# ls
news_backup.sh
[root@stapp01 scripts]# sh news_backup.sh
adding: var/www/html/news/ (stored 0%)
adding: var/www/html/news/index.html (stored 0%)
adding: var/www/html/news/.gitkeep (stored 0%)
xfusioncorp_news.zip 100% 588 975.0KB/s 00:00
[root@stapp01 scripts]# ll /backup
total 4
-rw-r–r-- 1 root root 588 Apr 10 10:48 xfusioncorp_news.zip
[root@stapp01 scripts]#
[root@stapp01 scripts]#
[root@stapp01 scripts]#
[root@stapp01 scripts]# ssh '[email protected] >>>>>>>>>>>>>>backup server
Last login: Sun Apr 10 10:46:37 2022 from stapp01
[clint@stbkp01 ~]$
[clint@stbkp01 ~]$
[clint@stbkp01 ~]$ ll /backup
total 4
-rw-r–r-- 1 clint clint 588 Apr 10 10:48 xfusioncorp_news.zip