Posted on July 27, 2021 1:13 pm
 |  Asked by yilmaz urgun
 |  107 views
0
0
Print Friendly, PDF & Email

Hello,

I want to send running config to central server periodically for backup,

I succeded to send running config using copy run commad as below:

##copy run scp://username@IP_address/home/username/$HOSTNAME.txt

But i can not use HOSTNAME value with command line copy command.

Do i have to use bash sudo command to use HOSTNAME value? and can i use switch’s crontab for this purpose?

(Software image version: 4.23.0F)

Thanks in advance.

1
Answered on July 27, 2021 1:23 pm

Hello,

You can go through the article below which explains various options to do so

https://eos.arista.com/how-to-backup-eos-configs-to-a-remote-server/

You can also use a simple cron job to automate backup log collection.

Below is an example from my lab:

bri500...10:03:18#bash
[admin@bri500 ~]$ sudo su
bash-4.2# crontab -e
* * * * * FastCli -p 15 -c "copy running-config scp:admin@10.85.128.91:/mnt/flash/weektest"

=============================================================================================

The above task saves the config every minute to the remote location as below

[admin@bri501 weektest]$ ls -ltr
total 144
-rw-rw-r--+ 1 admin eosadmin 8629 Sep 18 09:25 tmpgnBVVQ
-rw-rw-r--+ 1 admin eosadmin 8629 Sep 18 09:26 tmp0mUWox
-rw-rw-r--+ 1 admin eosadmin 8629 Sep 18 09:27 tmpqNaPIM
-rw-rw-r--+ 1 admin eosadmin 8629 Sep 18 09:28 tmpGe57IQ
-rw-rw-r--+ 1 admin eosadmin 8629 Sep 18 09:29 tmpPDrL21
-rw-rw-r--+ 1 admin eosadmin 8629 Sep 18 09:30 tmpi8JdPt

The interval is decided by the fields "* * * * *" preceding the command. Here the fields "A B C D E" correspond to "min hours days months days_of_week"

If you need to run it weekly, you can simply use the keyword "@weekly" or choose to customize the day/time using the above-mentioned fields. Few examples are available here https://www.tecmint.com/create-and-manage-cron-jobs-on-linux/

Additionally, you can open a case with TAC in case you run into any issues or are unable to push the config to the remote server.

Regards,
Pushkar

1
Posted by Shawn Rogers
Answered on July 27, 2021 2:24 pm

Hi Yilmaz,

If you would like to name your backup file the hostname of your device you can use the command below:

bash FastCli -p 15 -c "copy running-config scp:username@ip-addr:/mnt/flash/$HOSTNAME"

If you would like to name the file the hostname along with the date and time you can use the command below

bash FastCli -p 15 -c "copy running-config scp:username@ip-addr:/mnt/flash/$HOSTNAME-$(date +%m_%d.%H%M)"

Also, you can use EOS scheduler or crontab to run this command every X days/mins.

One thing to keep in mind is that SCP doesn't allow us to add the password in a single line, so when we run the command we will be prompted for a password(we would need to resolve this if we are going to use EOS scheduler or crontab).  To get around this issue we would either need to use SSH key authentication or a script that could send a password when prompted.

Thank You

Shawn Rogers

0
Posted by yilmaz urgun
Answered on July 30, 2021 11:15 am

Hello Pushkar, Shawn,

Thanks for your replies.

I tried ssh key authentication but everytime it promps the password. I sent public key of the sender (switch) to server's authorized keys file but it still asks password. And yes I enabled "PasswordAuthentication yes" on /etc/ssh/sshd_config on the server.

I tried ssh key authentication on my test Linux servers and it works. But couldnt make it between Arista switch and Linux server.

Do you want me open a TAC ticket or am I missing something?

Thanks and Regards

Yilmaz Urgun

 

Post your Answer

You must be logged in to post an answer.