Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    OpenVPN Backup Script

    Scheduled Pinned Locked Moved OpenVPN
    2 Posts 1 Posters 4.5k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B
      b00gz
      last edited by

      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"

      1 Reply Last reply Reply Quote 0
      • B
        b00gz
        last edited by

        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

        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.