Simple HP Aruba ProCurve and older swtiches backup script

#!/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"/

Use GMX as smarthost / relay_host with Postfix with separate transport_map

Excerpt /etc/postfix/main.cf
———————-
transport_maps = hash:/etc/postfix/transport
smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/sasl_password
sender_canonical_maps = hash:/etc/postfix/sender_canonical
smtp_tls_security_level = encrypt

 

Excerpt /etc/postfix/transport
————————
<mailaddress>@gmx.net smtp:mail.gmx.net:25

 

Excerpt /etc/postfix/sender_canonical
——————————-
root@proxmox sberg1@gmx.net

 

Excerpt /etc/postfix/sasl_password
—————————–
mail.gmx.net <mailaddress>@gmx.net:<password>

 

Execute postmap commands to create the hash db file from above transport / sender_canonical / sasl_password
—————————–
postmap transport
postmap sender_canonical
postmap sasl_password

 

Restart Postfix
————
systemctl restart postfix

 

Testing
——
mail -s test <mailaddress>@gmx.net
HINT: CC just hit <Enter> – then write the body followed by <Enter> and <.> (dot character) and again <Enter>- then quit the mail command by pressing <CTRL>-<D>