Arista EOS : sync dir and files between supervisor cards
Written by Arnaud no commentsI know some files (like startup-config) are synchronized between supervisor cards on Arista chassis :
DCS-7508N(s1)#show redundancy file-replication
0 files unsynchronized, 5 files synchronized, 0 files failed, 5 files total.
File Status Last Synchronized
---------------------------- ------------------ --------------------
file:persist/secure Synchronized 45 days, 5:52:41 ago
file:persist/sys Synchronized 0:04:05 ago
flash:.assetTags Synchronized 45 days, 5:52:41 ago
flash:startup-config Synchronized 0:38:59 ago
flash:zerotouch-config Synchronized 45 days, 5:52:42 ago
But I could not find any way to synchronize my homemade scripts easily, so I wrote a script to do it :
#! /usr/bin/bash
# Written by Arnaud Fenioux
# Copy files and directory recursively to the supervisor-peer for Arista EOS
# as "copy /recursive file:/mnt/flash/dir supervisor-peer:/mnt/flash/dir" if it had existed
# version 1.1
BIN=$(echo $0 | awk -F '/' '{print $NF}')
function print_log {
echo "$BIN: $1"
FastCli -p5 -c "send log message $BIN: $1"
}
function copy_rec {
for DIRFILE in $@ ; do
echo -ne "\nWorking on $DIRFILE... "
if [ -d "$DIRFILE" ]; then
#echo "dir!"
if $(FastCli -p 15 -c "dir supervisor-peer:$DIRFILE" | grep -q "% Error"); then
echo " Creating directory."
FastCli -p 15 -c "mkdir supervisor-peer:$DIRFILE"
fi
copy_rec $DIRFILE/*
elif [ -f "$DIRFILE" ]; then
#echo "file!"
FastCli -p 15 -c "copy file:$DIRFILE supervisor-peer:$DIRFILE"
else
echo "not found"
fi
done
}
print_log "Started"
if [[ $# -ge 1 ]]; then
copy_rec $@
else
# Batch copy
copy_rec /mnt/flash/schedule/*.sh
copy_rec /mnt/flash/docker
fi
print_log "Terminated"
You may now schedule this script to run everyday (or less!) :
DCS-7508N(s1)#conf
DCS-7508N(s1)(config)#schedule synch_sup at 10:00:00 interval 1440 timeout 60 max-log-files 7 command bash /mnt/flash/schedule/synch_sup.sh
Or trigger it on startup-config change (or some other action) :
DCS-7508N(s1)#conf session event-synch
<type your commands>
DCS-7508N(s1)(config-s-event-synch)#show session-config diffs
--- system:/running-config
+++ session:/event-synch-session-config
@@ -190,6 +190,13 @@
+event-handler synch_sup
+ trigger on-startup-config
+ action bash /mnt/flash/schedule/synch_sup.sh
+ delay 30
+ asynchronous
+ timeout 120
DCS-7508N(s1)(config-s-event-synch)#commit
DCS-7508N(s1)# write