Re: [BackupPC-users] Run VPN script before backup - PingCmd?

2021-07-13 Thread Adam Goryachev via BackupPC-users


On 14/7/21 00:18, Rob Morin wrote:

Wow, ok so that worked!

I put the Connect2Office.sh in the DumpPreUserCmd
It returns a zero as exit status too
And drops the vpn when done with DumpPostUserCmd

image.png

DumpPreUserCmd cript looks like this:

#!/bin/bash
sudo openvpn --daemon --config /etc/openvpn/gateway.hardent.com.ovpn
sleep 10
echo $?
/bin/true

DumpPostUserCmd looks like this:

#!/bin/bash
sudo killall openvpn
echo $?
/bin/true

You might consider a better method to ensure you close the "right" 
openvpn tunnel (there could be cases where you would have more than 
one). Usually the simplest would be to have the config on start create a 
pid file, then you can simply kill `cat /run/openvpn/mytunnel.pid`, it 
might also be an idea to confirm that the pid this file points to is 
actually (still) openvpn, but at least it's working for you now. The 
rest are just potential improvements you or someone else in future might 
need/want.

Thanks a bunch Adam.
I hope this helps others!
Have a great day everyone!


Regards,
Adam


On Mon, Jul 12, 2021 at 7:52 PM Adam Goryachev via BackupPC-users 
> wrote:



On 13/7/21 05:32, Rob Morin wrote:
> Hello all...
>
> I was looking at a way to start up my vpn from our remote backup
site
> to the office when backuppc starts a job.
>
> I googled around for quite a bit and saw some people were using  a
> script in place of the pingcmd parameter.
>
> I have tried that but i cant get it to work, as well as stop the
> connection when done using the PostDumpCmd.
>
> In a host, where the PingCmd text box is located i entered:
> /usr/local/bin/Connect2Office.sh
> And made sure the check mark was there and I saved it.
>
> The script itself is below, not much at all, really.
>
> #!/bin/bash
> /bin/true
> sudo openvpn --daemon --config /etc/openvpn/gateway.hardent.com.ovpn
> echo $?
>
> I added the --daemon in order to put the process in the
> background while running
> /bin/true is there because i thought the exit status had to be
something
> and the echo $? is there for same exit status reason.
>
> The user backuppc is allowed to sudo that script via the sudoers
file.
>
> Now , when I manually run this command as the user backuppc or
> root,  from the command line, all works well, and I can
manually start
> a backup and it completes fine.
>
> However, when I click on the start incremental job from GUI for the
> same host, as a test, the log file simply shows the below and
nothing
> gets backed up.
>
> 2021-07-12 14:49:45 incr backup started back to 2021-07-12 14:33:53
> (backup #0) for directory /etc
>
> Then after several minutes of nothing i dequeue the backup and
get the
> below, which is of course normal.
>
> 2021-07-12 14:51:26 Aborting backup up after signal INT
>
> I am sure I am doing something stupid
> Any help would be appreciated.
>
> Have a great day!
>
>
I'm not sure of using PingCmd for this, but why not use the
DumpPreUserCmd
http://backuppc.sourceforge.net/faq/BackupPC.html#_conf_dumppreusercmd_


? The stdout will be sent to the log for you to see what is happening.

As for the script, usually you would run the /bin/true as the last
command so that it will ignore any other exit status and always show
"successful". So based on the current script, that line is pointless
unless you moved it to after the openvpn command.

You might also need to check any capabilities, probably backuppc
doesn't
have NET_CAP or ability to create tunnels etc, so once you are
sure the
script is being run (maybe add a touch /tmp/myscript) then you might
want to define a openvpn log file so you can see what it is doing
and/or
why it fails

You might also need a sleep or some other test to ensure the
tunnel is
actually working/passing traffic, as openvpn will return before the
tunnel is up, and then backuppc will attempt to start the backup.

Regards,
Adam



___
BackupPC-users mailing list
BackupPC-users@lists.sourceforge.net

List: https://lists.sourceforge.net/lists/listinfo/backuppc-users

Wiki: https://github.com/backuppc/backuppc/wiki

Project: https://backuppc.github.io/backuppc/




--
--

Rob Morin
Systems/Network Administrator
Hardent Inc.
___
BackupPC-users mailing list
BackupPC-users@lists.sourceforge.net
List:

Re: [BackupPC-users] Run VPN script before backup - PingCmd?

2021-07-13 Thread Rob Morin
Wow, ok so that worked!

I put the Connect2Office.sh in the DumpPreUserCmd
It returns a zero as exit status too
And drops the vpn when done with DumpPostUserCmd

[image: image.png]

DumpPreUserCmd cript looks like this:

#!/bin/bash
sudo openvpn --daemon --config /etc/openvpn/gateway.hardent.com.ovpn
sleep 10
echo $?
/bin/true

DumprPostUserCmd looks like this:

#!/bin/bash
sudo killall openvpn
echo $?
/bin/true

Thanks a bunch Adam.
I hope this helps others!
Have a great day everyone!


On Mon, Jul 12, 2021 at 7:52 PM Adam Goryachev via BackupPC-users <
backuppc-users@lists.sourceforge.net> wrote:

>
> On 13/7/21 05:32, Rob Morin wrote:
> > Hello all...
> >
> > I was looking at a way to start up my vpn from our remote backup site
> > to the office when backuppc starts a job.
> >
> > I googled around for quite a bit and saw some people were using  a
> > script in place of the pingcmd parameter.
> >
> > I have tried that but i cant get it to work, as well as stop the
> > connection when done using the PostDumpCmd.
> >
> > In a host, where the PingCmd text box is located i entered:
> > /usr/local/bin/Connect2Office.sh
> > And made sure the check mark was there and I saved it.
> >
> > The script itself is below, not much at all, really.
> >
> > #!/bin/bash
> > /bin/true
> > sudo openvpn --daemon --config /etc/openvpn/gateway.hardent.com.ovpn
> > echo $?
> >
> > I added the --daemon in order to put the process in the
> > background while running
> > /bin/true is there because i thought the exit status had to be something
> > and the echo $? is there for same exit status reason.
> >
> > The user backuppc is allowed to sudo that script via the sudoers file.
> >
> > Now , when I manually run this command as the user backuppc or
> > root,  from the command line, all works well, and I can manually start
> > a backup and it completes fine.
> >
> > However, when I click on the start incremental job from GUI for the
> > same host, as a test, the log file simply shows the below and nothing
> > gets backed up.
> >
> > 2021-07-12 14:49:45 incr backup started back to 2021-07-12 14:33:53
> > (backup #0) for directory /etc
> >
> > Then after several minutes of nothing i dequeue the backup and get the
> > below, which is of course normal.
> >
> > 2021-07-12 14:51:26 Aborting backup up after signal INT
> >
> > I am sure I am doing something stupid
> > Any help would be appreciated.
> >
> > Have a great day!
> >
> >
> I'm not sure of using PingCmd for this, but why not use the
> DumpPreUserCmd
> http://backuppc.sourceforge.net/faq/BackupPC.html#_conf_dumppreusercmd_
> ? The stdout will be sent to the log for you to see what is happening.
>
> As for the script, usually you would run the /bin/true as the last
> command so that it will ignore any other exit status and always show
> "successful". So based on the current script, that line is pointless
> unless you moved it to after the openvpn command.
>
> You might also need to check any capabilities, probably backuppc doesn't
> have NET_CAP or ability to create tunnels etc, so once you are sure the
> script is being run (maybe add a touch /tmp/myscript) then you might
> want to define a openvpn log file so you can see what it is doing and/or
> why it fails
>
> You might also need a sleep or some other test to ensure the tunnel is
> actually working/passing traffic, as openvpn will return before the
> tunnel is up, and then backuppc will attempt to start the backup.
>
> Regards,
> Adam
>
>
>
> ___
> BackupPC-users mailing list
> BackupPC-users@lists.sourceforge.net
> List:https://lists.sourceforge.net/lists/listinfo/backuppc-users
> Wiki:https://github.com/backuppc/backuppc/wiki
> Project: https://backuppc.github.io/backuppc/
>


-- 

-- 

Rob Morin
Systems/Network Administrator
Hardent Inc.
___
BackupPC-users mailing list
BackupPC-users@lists.sourceforge.net
List:https://lists.sourceforge.net/lists/listinfo/backuppc-users
Wiki:https://github.com/backuppc/backuppc/wiki
Project: https://backuppc.github.io/backuppc/


Re: [BackupPC-users] Run VPN script before backup - PingCmd?

2021-07-12 Thread Adam Goryachev via BackupPC-users


On 13/7/21 05:32, Rob Morin wrote:

Hello all...

I was looking at a way to start up my vpn from our remote backup site 
to the office when backuppc starts a job.


I googled around for quite a bit and saw some people were using  a 
script in place of the pingcmd parameter.


I have tried that but i cant get it to work, as well as stop the 
connection when done using the PostDumpCmd.


In a host, where the PingCmd text box is located i entered:
/usr/local/bin/Connect2Office.sh
And made sure the check mark was there and I saved it.

The script itself is below, not much at all, really.

#!/bin/bash
/bin/true
sudo openvpn --daemon --config /etc/openvpn/gateway.hardent.com.ovpn
echo $?

I added the --daemon in order to put the process in the 
background while running

/bin/true is there because i thought the exit status had to be something
and the echo $? is there for same exit status reason.

The user backuppc is allowed to sudo that script via the sudoers file.

Now , when I manually run this command as the user backuppc or 
root,  from the command line, all works well, and I can manually start 
a backup and it completes fine.


However, when I click on the start incremental job from GUI for the 
same host, as a test, the log file simply shows the below and nothing 
gets backed up.


2021-07-12 14:49:45 incr backup started back to 2021-07-12 14:33:53 
(backup #0) for directory /etc


Then after several minutes of nothing i dequeue the backup and get the 
below, which is of course normal.


2021-07-12 14:51:26 Aborting backup up after signal INT

I am sure I am doing something stupid
Any help would be appreciated.

Have a great day!


I'm not sure of using PingCmd for this, but why not use the 
DumpPreUserCmd 
http://backuppc.sourceforge.net/faq/BackupPC.html#_conf_dumppreusercmd_ 
? The stdout will be sent to the log for you to see what is happening.


As for the script, usually you would run the /bin/true as the last 
command so that it will ignore any other exit status and always show 
"successful". So based on the current script, that line is pointless 
unless you moved it to after the openvpn command.


You might also need to check any capabilities, probably backuppc doesn't 
have NET_CAP or ability to create tunnels etc, so once you are sure the 
script is being run (maybe add a touch /tmp/myscript) then you might 
want to define a openvpn log file so you can see what it is doing and/or 
why it fails


You might also need a sleep or some other test to ensure the tunnel is 
actually working/passing traffic, as openvpn will return before the 
tunnel is up, and then backuppc will attempt to start the backup.


Regards,
Adam



___
BackupPC-users mailing list
BackupPC-users@lists.sourceforge.net
List:https://lists.sourceforge.net/lists/listinfo/backuppc-users
Wiki:https://github.com/backuppc/backuppc/wiki
Project: https://backuppc.github.io/backuppc/