Monitoring, Management & Location Tracking

How to SCP the nightly backup files to external server Automatically from Airwave
Requirement:

Need to Transfer the nightly backup from Airwave to an external SCP server every day at 3 am Automatically.

 

This KB Works for any Airwave version, and need a valid SCP server which can receive files from the Airwave, basically the connectivity.



Solution:

We could create a simple bash script, with the commands to scp the file to the external SCP server and set a cron job to run that script, every day at 3 am in the morning.



Configuration:

Normally the SCP command will require the username and password to initiate the transfer.  

We cannot manually enter the password every to Automate the process. Therefore we will need the "sshpass" rpm installed on our Airwave, so that we can use it to put the password automatically for us.

We could download the "sshpass" rpm from the below URL:

https://sourceforge.net/projects/sshpass/

and I have also attached the URL to this KB, we could just copy the rpm file to any directory on Airwave and execute the below command from that directory:

# rpm -Uvh  sshpass-1.05-1.el6.x86_64.rpm

 

The SCP command will look like this:

# sshpass -p 'password' scp /var/airwave-backup/nightly_data001.tar.gz  username@<ip of the remote server>:/<backup_directory>/

In the above command, 'password' is the password of the remote server inside single quotes, sshpass tool will provide the password automatically every time this command gets executed, instead of user entering it manually.

This command will transfer the nightly_data001.tar.gz file, which is the latest backup file to the "backup_directory" a directory on the remote server.

 

Now we could create a simple bash script to run this command, by doing the following:

# vi /tmp/scpscript.sh

Note: I am creating this script in /tmp directory, you could create in any directory you prefer.

The above command will open Vi editor, where we can type the content into the file by pressing the alphabet "i" in the key board, which is insert mode. enter the following in the script:

#!/bin/bash
# Script to transfer the file to scp server
sshpass -p '<password>' scp /var/airwave-backup/nightly_data001.tar.gz <username>@<ip of the remote server>:/<backup_directory>/
#end

after typing the above content in the script, we would need to save and exit. by doing the following:

hit the "Esc" key following with ":" (colon)  wq!

once the script is saved, we need to give it executable file permissions by running the below command:

# chmod 755 /tmp/scpscript.sh

 

Now we could Automate this script to run every day at 3 am by editing the cronjob file, by running the below command:

# crontab -e

Hit "i" to insert, after # End AMP CRON ENTRIES, we need to type the below:

00 03 * * * /tmp/./scpscript.sh

and do the following to save and exit:

hit the "Esc" key following with ":" (colon)  wq!

 

Done.

 

 

 

 

 

 

 

 

 

 



Verification

We could do the following to look at the crotab file, the output of the file should look something like this:

 

[root@localhost mercury]# crontab -l
# BEGIN AMP CRON ENTRIES
15 04 * * * /usr/local/airwave/bin/nightly_maintenance_exclusive /usr/local/airwave/bin/nightly_maintenance

# END AMP CRON ENTRIES

00 03 * * * /tmp/./scpscript.sh


[root@localhost mercury]#

 


Attachments:
sshpass-1.05-1.el6.x86_64.rpm
Version history
Revision #:
2 of 2
Last update:
‎11-21-2016 02:33 AM
Updated by:
 
Labels (1)
Contributors
Search Airheads
Showing results for 
Search instead for 
Did you mean: 
Is this a frequent problem?

Request an official Aruba knowledge base article to be written by our experts.