OPNsense
  • Home
  • Help
  • Search
  • Login
  • Register

  • OPNsense Forum »
  • English Forums »
  • General Discussion »
  • [SOLVED] Backup OPSsense configuration with wget
« previous next »
  • Print
Pages: 1 [2] 3

Author Topic: [SOLVED] Backup OPSsense configuration with wget  (Read 21460 times)

orsomannaro

  • Newbie
  • *
  • Posts: 10
  • Karma: 0
    • View Profile
Re: Backup OPSsense configuration with wget
« Reply #15 on: March 09, 2017, 09:21:20 am »
Quote from: fabian on March 04, 2017, 12:42:20 pm
Do you use 17.1.2?

Updating OPSsense to version 17.1.2 the script works fine.

Thank you so much Fabian!
Logged

Perun

  • Jr. Member
  • **
  • Posts: 99
  • Karma: 0
    • View Profile
Re: [SOLVED] Backup OPSsense configuration with wget
« Reply #16 on: February 02, 2018, 09:19:08 am »
does someone have a sh script for this?
Logged

franco

  • Administrator
  • Hero Member
  • *****
  • Posts: 17707
  • Karma: 1618
    • View Profile
Re: [SOLVED] Backup OPSsense configuration with wget
« Reply #17 on: February 02, 2018, 09:25:06 am »
As stated previously, that script should to do fine without bash. Can always check with "sh -n script.sh".
Logged

Perun

  • Jr. Member
  • **
  • Posts: 99
  • Karma: 0
    • View Profile
Re: [SOLVED] Backup OPSsense configuration with wget
« Reply #18 on: February 02, 2018, 09:47:46 am »
hmm it doesnt work for me...

I have modified it a little:
Code: [Select]
#!/bin/sh
 
TMP=$(mktemp -d)
URL=$1
LOGIN='mybackupuser'
PASS='mybackuppass'
 
# Submit the login form with the previous values, and save a new CSRF token
/usr/bin/wget -q -O /dev/null --keep-session-cookies --save-cookies $TMP/cookies.txt --no-check-certificate  \
   --post-data "login=Login&usernamefld=$LOGIN&passwordfld=$PASS" $URL/diag_backup.php
 
# Save only the config
/usr/bin/wget -q --keep-session-cookies --load-cookies $TMP/cookies.txt --save-cookies $TMP/cookies.txt --no-check-certificate \
    --post-data "download=Download%20Configuration&donotbackuprrd=yes" $URL/diag_backup.php -O /srv/backup/config-$1-`date +%Y%m%d%H%M%S`.xml \
 
rm -f $TMP/*.txt
rmdir $TMP

gave the mybackupusr the permission to 'see' the backup site

and got this in /srv/backup/config-myhost-20180202094316.xml:

Code: [Select]
<!doctype html>
<!--[if IE 8 ]><html lang="en" class="ie ie8 lte9 lte8 no-js"><![endif]-->
<!--[if IE 9 ]><html lang="en" class="ie ie9 lte9 no-js"><![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--><html lang="en" class="no-js"><!--<![endif]-->
  <head>

    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

    <meta name="robots" content="noindex, nofollow, noodp, noydir" />
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    <meta name="copyright" content="" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />

    <title>Login</title>

    <link href="/ui/themes/opnsense/build/css/main.css" rel="stylesheet">
    <link href="/ui/themes/opnsense/build/images/favicon.png" rel="shortcut icon">

    <script type="text/javascript" src="/ui/js/jquery-3.2.1.min.js"></script>
    <script type="text/javascript" src="/ui/js/jquery-migrate-3.0.1.min.js"></script>


    <!--[if lt IE 9]><script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.min.js"></script><![endif]-->

 
            <script type="text/javascript">
              $( document ).ready(function() {
                  $.ajaxSetup({
                  'beforeSend': function(xhr) {
                      xhr.setRequestHeader("X-CSRFToken", "SEtpaEhPdXN6OWlQMmphdHdxNitadz09" );
                  }
                });
              });
            </script>
            </head>
  <body class="page-login">

  <div class="container">
   
    <main class="login-modal-container">
      <header class="login-modal-head" style="height:55px;">
        <div class="navbar-brand">
          <img src="/ui/themes/opnsense/build/images/default-logo.png" height="30" alt="logo"/>
        </div>
      </header>

      <div class="login-modal-content">
        <div id="inputerrors" class="text-danger">&nbsp;</div><br />

            <form class="clearfix" id="iform" name="iform" method="post" autocomplete="off" action="/diag_backup.php"><input type="hidden" name="RFlMUHFrV3p1M1RqNzhEcFdINFZLdz09" value="SEtpaEhPdXN6OWlQMmphdHdxNitadz09" />

        <div class="form-group">
          <label for="usernamefld">Username:</label>
          <input id="usernamefld" type="text" name="usernamefld" class="form-control user" tabindex="1" autofocus="autofocus" autocapitalize="off" autocorrect="off" />
        </div>

        <div class="form-group">
          <label for="passwordfld">Password:</label>
          <input id="passwordfld" type="password" name="passwordfld" class="form-control pwd" tabindex="2" />
        </div>

        <button type="submit" name="login" value="1" class="btn btn-primary pull-right">Login</button>

      </form>

     
          </div>

      </main>
      <div class="login-foot text-center">
        <a target="_blank" href="https://opnsense.org/" class="redlnk">OPNsense</a> (c) 2014-2018        <a href="https://www.deciso.com/" class="tblnk">Deciso B.V.</a>
      </div>

    </div>

    </body>
  </html>

Greetz
Logged

fabian

  • Hero Member
  • *****
  • Posts: 2769
  • Karma: 200
  • OPNsense Contributor (Language, VPN, Proxy, etc.)
    • View Profile
    • Personal Homepage
Re: [SOLVED] Backup OPSsense configuration with wget
« Reply #19 on: February 02, 2018, 08:14:03 pm »
This means you are not authenticated.
Logged

ccesario

  • Jr. Member
  • **
  • Posts: 83
  • Karma: 1
    • View Profile
Re: [SOLVED] Backup OPSsense configuration with wget
« Reply #20 on: September 17, 2018, 02:31:38 pm »
Hi Folks, this script is it working ?

Im testint it with 18.7 series withou success.

best regards

Carlos
Logged

fabian

  • Hero Member
  • *****
  • Posts: 2769
  • Karma: 200
  • OPNsense Contributor (Language, VPN, Proxy, etc.)
    • View Profile
    • Personal Homepage
Re: [SOLVED] Backup OPSsense configuration with wget
« Reply #21 on: September 17, 2018, 05:40:23 pm »
Just tested it - yes it works. Are you missing a dependency or the credentials?
Logged

gislaved

  • Newbie
  • *
  • Posts: 10
  • Karma: 0
    • View Profile
Re: [SOLVED] Backup OPSsense configuration with wget
« Reply #22 on: February 10, 2019, 05:25:12 pm »
Am I right if this doesn't work at all on 19.x ?

If it should work please add a working example.

Thanks!
Logged

franco

  • Administrator
  • Hero Member
  • *****
  • Posts: 17707
  • Karma: 1618
    • View Profile
Re: [SOLVED] Backup OPSsense configuration with wget
« Reply #23 on: February 10, 2019, 05:30:30 pm »
> Am I right if this doesn't work at all on 19.x ?

No, it is ok.
Logged

gislaved

  • Newbie
  • *
  • Posts: 10
  • Karma: 0
    • View Profile
Re: [SOLVED] Backup OPSsense configuration with wget
« Reply #24 on: February 10, 2019, 05:45:44 pm »
Quote from: franco on February 10, 2019, 05:30:30 pm
> Am I right if this doesn't work at all on 19.x ?

No, it is ok.

Can you please post a working, tested, example as reference ? I think it clears up the topic as well. Thanks!
Logged

franco

  • Administrator
  • Hero Member
  • *****
  • Posts: 17707
  • Karma: 1618
    • View Profile
Re: [SOLVED] Backup OPSsense configuration with wget
« Reply #25 on: February 10, 2019, 05:58:34 pm »
install os-api-backup plugin and see https://github.com/opnsense/plugins/pull/895#issuecomment-458158323
Logged

gislaved

  • Newbie
  • *
  • Posts: 10
  • Karma: 0
    • View Profile
Re: [SOLVED] Backup OPSsense configuration with wget
« Reply #26 on: February 10, 2019, 06:01:13 pm »
Quote from: franco on February 10, 2019, 05:58:34 pm
install os-api-backup plugin and see https://github.com/opnsense/plugins/pull/895#issuecomment-458158323

That is not the bashscript I requested for. I want to do something else with bash as well, like exporting certificates but want to have this working first.

I'm looking forward to it :)
Logged

franco

  • Administrator
  • Hero Member
  • *****
  • Posts: 17707
  • Karma: 1618
    • View Profile
Re: [SOLVED] Backup OPSsense configuration with wget
« Reply #27 on: February 10, 2019, 06:02:35 pm »
This topic is about config.xml backups, sorry.
Logged

gislaved

  • Newbie
  • *
  • Posts: 10
  • Karma: 0
    • View Profile
Re: [SOLVED] Backup OPSsense configuration with wget
« Reply #28 on: February 10, 2019, 06:30:17 pm »
Quote from: franco on February 10, 2019, 06:02:35 pm
This topic is about config.xml backups, sorry.

Which I try to get with a working bash script you say which is working referring to a script you are not wiling to (re)post ?

From that I can see what I do else but this is my base, so please share what you say you have working or is working.

Thanks again!
Logged

franco

  • Administrator
  • Hero Member
  • *****
  • Posts: 17707
  • Karma: 1618
    • View Profile
Re: [SOLVED] Backup OPSsense configuration with wget
« Reply #29 on: February 11, 2019, 08:48:48 am »
I'm only trying to help and I feel you're not accepting it. I'm sorry I cannot communicate this any better.
Logged

  • Print
Pages: 1 [2] 3
« previous next »
  • OPNsense Forum »
  • English Forums »
  • General Discussion »
  • [SOLVED] Backup OPSsense configuration with wget
 

OPNsense is an OSS project © Deciso B.V. 2015 - 2024 All rights reserved
  • SMF 2.0.19 | SMF © 2021, Simple Machines
    Privacy Policy
    | XHTML | RSS | WAP2