git config --global user.email "[email address for your backup user]" git config --global user.name "[name for your backup user]" file1="$gitbackupdir/backup-config/targets" read -d $'\x04' targets < "$file1" file2="$gitbackupdir/backup-config/username" read -d $'\x04' username < "$file2" password=$(cat /run/secrets/net-access-decode-pw | gpg --batch --passphrase-fd -o- -d /infrastructure-configs/backup-config/code.gpg) echo "backing up targets - " echo $targets echo "using account - " echo $username echo "" echo "---------------------------------" echo "-- starting config acquisition --" echo "" for device in $targets ; do # Copy startup and running config to git repo mkdir -p $gitbackupdir/backups/$device echo $device sshpass -p $password scp $username@$device:system:/running-config $gitbackupdir/backups/$device/running-config sshpass -p $password scp $username@$device:startup-config $gitbackupdir/backups/$device/startup-config done echo "" echo "-- config aquisition completed --" echo "" echo "-- uploading configs to github --" echo "" cd $gitbackupdir git add . git commit -m "Config backup from $(date)" git push echo"" echo "-- upload config to git completed --"