#!/bin/bash
#
#
# Some vars
DATE=$(date +“%F_%H-%M_“)
DIRDATE=$(date +“%F_%H-%M“)
SSHPASSCMD=“/usr/bin/sshpass -f“
MKDIRCMD=“/bin/mkdir -p“
CIPHER=“aes128-cbc“
KEYEX=“-oKexAlgorithms=diffie-hellman-group14-sha1″
# Deleting old files and directories
find /home/backups/data/switches/old-switch1 -type d,f -mtime +2 -exec rm -rf {} \;
find /home/backups/data/switches/old-switch2 -type d,f -mtime +2 -exec rm -rf {} \;
find /home/backups/data/switches/procurve-switch1 -type d,f -mtime +2 -exec rm -rf {} \;
find /home/backups/data/switches/procurve-switch2 -type d,f -mtime +2 -exec rm -rf {} \;
# old school switch 1
$MKDIRCMD /home/backups/data/switches/old-switch1/“$DIRDATE“
$SSHPASSCMD /home/backups/scripts/switches-config/old-switch1.cfg /usr/bin/scp -c $CIPHER $KEYEX admin@old-switch1.domain.tld:/startup.cfg /home/backups/data/switches/old-switch1/“$DIRDATE“/
$SSHPASSCMD /home/backups/scripts/switches-config/old-switch1.cfg /usr/bin/scp -c $CIPHER $KEYEX admin@old-switch1.domain.tld:/company_legacy_ca.crt /home/backups/data/switches/old-switch1/“$DIRDATE“/
$SSHPASSCMD /home/backups/scripts/switches-config/old-switch1.cfg /usr/bin/scp -c $CIPHER $KEYEX admin@old-switch1.domain.tld:/https-server.p12 /home/backups/data/switches/old-switch1/“$DIRDATE“/
$SSHPASSCMD /home/backups/scripts/switches-config/old-switch1.cfg /usr/bin/scp -c $CIPHER $KEYEX admin@old-switch1.domain.tld:/v1910-cmw520-r1513p62.bin /home/backups/data/switches/old-switch1/“$DIRDATE“/
# old school switch 2
$MKDIRCMD /home/backups/data/switches/old-switch2/“$DIRDATE“
$SSHPASSCMD /home/backups/scripts/switches-config/old-switch2.cfg /usr/bin/scp -c $CIPHER $KEYEX admin@old-switch2.domain.tld:/startup.cfg /home/backups/data/switches/old-switch2/“$DIRDATE“/
$SSHPASSCMD /home/backups/scripts/switches-config/old-switch2.cfg /usr/bin/scp -c $CIPHER $KEYEX admin@old-switch2.domain.tld:/_startup_bak.cfg /home/backups/data/switches/old-switch2/“$DIRDATE“/
$SSHPASSCMD /home/backups/scripts/switches-config/old-switch2.cfg /usr/bin/scp -c $CIPHER $KEYEX admin@old-switch2.domain.tld:/old-switch2-chain.crt /home/backups/data/switches/old-switch2/“$DIRDATE“/
$SSHPASSCMD /home/backups/scripts/switches-config/old-switch2.cfg /usr/bin/scp -c $CIPHER $KEYEX admin@old-switch2.domain.tld:/company_local.cer /home/backups/data/switches/old-switch2/“$DIRDATE“/
$SSHPASSCMD /home/backups/scripts/switches-config/old-switch2.cfg /usr/bin/scp -c $CIPHER $KEYEX admin@old-switch2.domain.tld:/company_ca.cer /home/backups/data/switches/old-switch2/“$DIRDATE“/
$SSHPASSCMD /home/backups/scripts/switches-config/old-switch2.cfg /usr/bin/scp -c $CIPHER $KEYEX admin@old-switch2.domain.tld:/jg927a-cmw520-r1119.bin /home/backups/data/switches/old-switch2/“$DIRDATE“/
# procurve-switch1
$MKDIRCMD /home/backups/data/switches/procurve-sw001/"$DIRDATE"
$SSHPASSCMD /home/backups/scripts/switches-config/procurve-sw001.cfg /usr/bin/scp $KEYEX -r manager@procurve-sw001.domain.tld:/cfg /home/backups/data/switches/procurve-sw001/"$DIRDATE"/
$SSHPASSCMD /home/backups/scripts/switches-config/procurve-sw001.cfg /usr/bin/scp $KEYEX -r manager@provurce-sw001.domain.tld:/os /home/backups/data/switches/procurve-sw001/"$DIRDATE"/
# procurve-switch2
$MKDIRCMD /home/backups/data/switches/procurve-sw002/"$DIRDATE"
$SSHPASSCMD /home/backups/scripts/switches-config/procurve-sw002.cfg /usr/bin/scp $KEYEX -r manager@procurve-sw002.domain.tld:/cfg /home/backups/data/switches/procurve-sw002/"$DIRDATE"/
$SSHPASSCMD /home/backups/scripts/switches-config/procurve-sw002.cfg /usr/bin/scp $KEYEX -r manager@procurve-sw002.domain.tld:/os /home/backups/data/switches/procurve-sw002/"$DIRDATE"/