Rozdíly

Zde můžete vidět rozdíly mezi vybranou verzí a aktuální verzí dané stránky.

Odkaz na výstup diff

Obě strany předchozí revize Předchozí verze
Následující verze
Předchozí verze
cisco:skript_pro_zalohovani_konfigurace [27.02.2013 08:13]
mtalma [backup.sh]
cisco:skript_pro_zalohovani_konfigurace [13.03.2020 18:43] (aktuální)
Řádek 3: Řádek 3:
 ===== backup.sh ===== ===== backup.sh =====
 <code bash> <code bash>
 +
 #!/bin/sh #!/bin/sh
  
-SCRIPT=/usr/local/bin/backupsw.exp 
 ARCHIVE="sw-backup.tar.gz" ARCHIVE="sw-backup.tar.gz"
-IP="10.163.8.11 +TFTP="tftp://10.153.1.34/sw" 
-    10.163.8.12 +TFTP_DIR="/srv/tftp/sw" 
-    10.170.2.35 +IP="10.153.1.10 
-    10.170.2.39"+    10.153.1.17 
 +    "
  
-rm -f /srv/tftp/*.log 
 for ip in $IP; for ip in $IP;
 do do
-    echo $ip + echo $ip 
-    $SCRIPT $ip >> /srv/tftp/$ip.log+ echo =========================
  
-/usr/bin/expect -f <<EOD+/usr/bin/expect <<EOD
 set timeout 20 set timeout 20
  
-# tftp server +spawn telnet $ip
-set tftp "10.163.7.180"+
  
-# router user name 
-set name "atmin" 
- 
-# router password 
-set pass "heslo" 
- 
-# start telnet 
-spawn telnet $IP 
- 
-# send username and password 
 expect "ame:" expect "ame:"
-send "$name\r" +send "admin\r" 
-expect "Password:" +expect "assword:" 
-send "$pass\r"+send "LanAdmin11\r"
  
 expect "#" expect "#"
-send "copy running-config tftp://$tftp/sw-$IP.cfg\r" +send "copy running-config $TFTP/sw-$ip.cfg\r"
 expect "?" expect "?"
 send "\r" send "\r"
Řádek 47: Řádek 35:
 send "\r" send "\r"
 expect "#" expect "#"
- 
 EOD EOD
  
 done done
  
-tar -zcf /tmp/$ARCHIVE /srv/tftp/* +tar -zcf /tmp/$ARCHIVE $TFTP_DIR/* 
-uuencode /tmp/$ARCHIVE $ARCHIVE | mail -s "Constellium switches backup" email@email.cz+uuencode /tmp/$ARCHIVE $ARCHIVE | mail -s "Switches backup" email@email.cz
 rm -f /tmp/$ARCHIVE rm -f /tmp/$ARCHIVE
 +
 </code> </code>
  
-===== backupsw.exp===== 
-<code> 
-#!/usr/bin/expect -f 
-set timeout 20 
- 
-# tftp server 
-set tftp "10.163.7.180" 
- 
-# router user name 
-set name "atmin" 
- 
-# router password 
-set pass "heslo" 
- 
-# start telnet 
-spawn telnet [lindex $argv 0] 
- 
-# send username and password 
-expect "ame:" 
-send "$name\r" 
-expect "Password:" 
-send "$pass\r" 
- 
-expect "#" 
-send "copy running-config tftp://$tftp/sw-[lindex $argv 0].cfg\r" 
- 
-expect "?" 
-send "\r" 
-expect "?" 
-send "\r" 
-expect "#" 
-</code> 
  
cisco/skript_pro_zalohovani_konfigurace.1361952784.txt.gz · Poslední úprava: 13.03.2020 18:43 (upraveno mimo DokuWiki)
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0