Copy and paste again

. The configuration is just an script, when you copy and paste, the switch will execute line per line as a command.
You can copy the config file using tftp and save into nvram as "startup-config", them just restart the switch, but can be dangerous cause the backuped file can be corrupted.
To make backups, I have created a script, like this:
#!/bin/bash
#Resp.: Leonardo Ortiz
rfs_sc1="10.9.40.49"
rfs_sc2="10.9.40.50"
rfs_ce1="10.200.40.49"
rfs_ce2="10.200.40.50"
echo "--------- Script $(basename $0)- $(date +%d/%m/%Y-%H:%M:%S) iniciado --------" >> /marisol/log/rfs6000/$(basename $0)-$(date +%d-%m-%Y).log
remover_antigos(){
find /marisol/backup/rfs6000 -mtime +31 -exec rm -f {} \;
}
for rfs in $rfs_sc1 $rfs_sc2 $rfs_ce1 $rfs_ce2; do
[ $rfs = "10.9.40.49" ] && rfsver="rfs-sc-primario"
[ $rfs = "10.9.40.50" ] && rfsver="rfs-sc-secundario"
[ $rfs = "10.200.40.49" ] && rfsver="rfs-ce-primario"
[ $rfs = "10.200.40.50" ] && rfsver="rfs-ce-secundario"
expect -c "
spawn ssh -l admin "$rfs"
expect \"Username\"
send \"admin \r\"
expect \"Password\"
send \"superuser \r\"
expect \"\n\"
send \"enable\n\"
expect \"\n\"
send \"write\n\"
send \"copy startup-config ftp://rfs6000:wireless@10.9.3.57/$rfsver-$(date +%d-%m-%Y)\n\"
expect \"%\"
send \"exit\r\"
" >> /marisol/log/rfs6000/$(basename $0)-$(date +%d-%m-%Y).log
done
#compactar os arquivos
cd /marisol/backup/rfs6000/ && tar -czf rfs6000-$(date +%d-%m-%Y).tar.gz *$(date +%d-%m-%Y)
rm -f /marisol/backup/rfs6000/*$(date +%d-%m-%Y)
remover_antigos
echo -e "\n--------- Script $(basename $0)- $(date +%d/%m/%Y-%H:%M:%S) executado com sucesso --------" >> /marisol/log/rfs6000/$(basename $0)-$(date +%d-%m-%Y).log
This script make a backup and save into my Linux Machine. The script delete old backups (more than 1 month).