Few customers reported that they need to automate their backup to a Data server which is Unix/Linux based server. To do this SCP is the easiest way to copy/transfer a backup file from Airwave server to Different Linux server.
Environment : Applicable for Linux and Unix based machines.
1. First you need to generate a key from Airwave server for for ssh communication without password to Data server.
a. on Data server:
# touch /root/.ssh/authorized.keys
# chmod 644 /root/.ssh/aurthorized.keys
b. On Airwave server :
# ssh-keygen -t
NOTE: press enter - enter do not provide any password here.
# cd /root/.ssh/
# ls (check for id_rsa.pub)
# scp /root/.ssh/id_rsa.pub root@<p address of the destination serve>:/root/.ssh/authorized.keys
Here it will prompt for the root password for destination server.
2. Create a one liner script:
a. # vi /tmp/scriptscp.sh
b. add lines as below-
scp /var/airwave-backup/<name of the latest nightly backup file> root@<ip address of the destination server>:/tmp/airwave-latest-backup/
Save and exit.
Then, # chmod -777 /tmp/scriptscp.sh
3. In destination server create "airwave-latest-backup" directory.
a. mkdir -p /tmp/airwave-latest-backup
b. chmod 777 /tmp/airwave-latest-backup
4. Now we need to create a cronjob to auto run the script.
a. # crontab -e
b. add a line as below-
30 10 * * * /tmp/scriptscp.sh
*If you want to delete file after SCP the put the below line in crontab.
30 12 * * * rm -f /var/airwave-backup/<backup file as mentioned above> (This line would not be recommended because it will remove the backup file from server or if customer is using failover server the do not add this line)
Save and exit