Harapkan mungkin calon yang baik untuk dipertimbangkan untuk pekerjaan itu.
Di bawah ini adalah contoh template yang telah saya kumpulkan yang dikomentari untuk Anda mainkan. Ini akan masuk ke WLC, ambil konfigurasi yang sedang berjalan dan menambahkannya ke file pilihan Anda.
Contoh nama file dan lokasi adalah /var/log/script-log/config-log.txt
Anda harus mengubah nama file dan lokasi menjadi file pilihan Anda (dengan izin yang memadai) serta nama pengguna, kata sandi, dan alamat IP WLC Anda.
Akhirnya Anda dapat mengedit crontab Anda untuk menjalankan skrip cadangan menggunakan interval yang diinginkan.
Contoh crontab:
# Run configuration backup every night at midnight
0 0 * * * /path/to/script/script-name
Contoh skrip cadangan konfigurasi:
#!/usr/bin/expect
set timeout 15
set user "username-here"
set password "password-here"
set ipaddress1 "ip-address-here"
# Store the current date in 'date' and add header to log for appending separation
catch { exec sh -c { date } } date
set env(date) "$date"
exec sh -c {
{
echo -e "\n\n==================================================="
echo -e "= WLC Configuration - $date"
echo -e "===================================================\n\n"
} >>/var/log/script-log/config-log.txt
}
# Log to the log.txt file and append to the log on subsequent runs (a)
set log [open "/var/log/script-log/config-log.txt" a]
set accum {}
# Expect diagnostic information with 1 | off = 0
exp_internal 0
# View stdout with 1 | off = 0
log_user 0
# Connect to physical WLC (ipaddr) with ssh
spawn ssh $ipaddress1
match_max 100000
sleep 1
match_max [expr 32 * 1024]
while 1 {
expect {
"no)?" {send "yes\r"}
"n as:*" {send "$user\r"}
"ser:*" {send "$user\r"}
"assword:*" {send "$password\r"}
"r) >" {break}
"denied" {send_user "Can't login\r"; exit 1}
"refused" {send_user "Connection refused\r"; exit 2}
"failed" {send_user "Host exists. Check ssh_hosts file\r"; exit 3}
timeout {send_user "Timeout problem\r"; exit 4}
}
}
# send carriage return (\r) to make sure we get back to CLI prompt
send "\r"
sleep 1
# Remove scroll limit and show running configuration
send "config paging disable\r"
sleep 1
send "show run-config\r"
sleep 1
expect {
"nue..." {send "\r"}
}
sleep 1
send "logout\r"
sleep 1
# Upon logging out you can either save any pending changes with y or simply use n to ignore them
send "y\r"
sleep 4
# Grab string that matched the greedy regexp
expect {
-regexp {..*} {
set accum "${accum}$expect_out(0,string)"
exp_continue
}
}
puts $log $accum