OpenVPN Backup Script
-
Guys,
I currently am using a windows box to run this script to backup firewalls. What I would like to do (can be done in Linux or Windows) is use a computer and have it have OpenVPN client certs and have it connect to client 1 backup the firewall and then disconnect … next connect to client 2 backup the firewall and then disconnect. Anyone have any ideas on how I can script connects and disconnects ... like I said this can be done in Linux or Windows (preferable Linux). All help is appreciated.
FOR /f "tokens=2-4 delims=/ " %%a in ('DATE/T') do SET tmpdt=%%a-%%b-%%c
wget -q --post-data=Submit=download --http-user=username --http-passwd=password --no-check-certificate https://10.0.0.1:10443/diag_backup.php -O "D:\backups\firewall%tmpdt%-firewall-config.xml" -
Still would like to know how to do this in Linux but I figured it out in Windows. I am going to try some more with Linux later tonight.
I downloaded PSKill for windows and was able to accomplish this by using 2 scripts. Run the Connect_Script then Run Disconnect_And_Backup_Script 10 seconds or so after.
PSKill can be downloaded here http://technet.microsoft.com/en-us/sysinternals/bb896683.aspx
Connect_Script.bat
openvpn –config "C:\path\to\file.ovpn"Disconnect_And_Backup_Script.bat
FOR /f "tokens=2-4 delims=/ " %%a in ('DATE/T') do SET tmpdt=%%a-%%b-%%c
wget -q --post-data=Submit=download --http-user=username --http-passwd=password --no-check-certificate https://IP:PORT/diag_backup.php -O "C:\path\to\backup%tmpdt%-firewall-config.xml"
pskill openvpn.exe