How to shutdown bareos server after last backup?

101 views
Skip to first unread message

Udo Claushues

unread,
Dec 15, 2015, 4:38:58 PM12/15/15
to bareos-users

Hi,

I use bareos for my backup at home.

To save energy, i'd like to shutdown the server after the backup of the bareos catalog (last job).

How can i shutdown the server?

When i add this RunAfterJob command in bareos-dir.conf:

RunAfterJob = "/sbin/poweroff"


I get the following error: ... AfterJob: shutdown: Need to be root

Philipp Storz

unread,
Dec 16, 2015, 3:25:40 AM12/16/15
to bareos...@googlegroups.com
Hello,

On 15.12.2015 22:38, Udo Claushues wrote:
>
> Hi,
>
> I use bareos for my backup at home.
>
> To save energy, i'd like to shutdown the server after the backup of the bareos catalog (last job).
>
> How can i shutdown the server?
>
> When i add this RunAfterJob command in bareos-dir.conf:
>
> RunAfterJob = "/sbin/poweroff"

This is executed by the director, and that runs as user bareos.

Try
"Client Run After Job"

as this is executed by the fd and it runs as root.

>
>
> I get the following error: ... AfterJob: shutdown: Need to be root
>
>
>
>
>
>
>


--
Mit freundlichen Grüßen

Philipp Storz philip...@bareos.com
Bareos GmbH & Co. KG Phone: +49 221 63 06 93-92
http://www.bareos.com Fax: +49 221 63 06 93-10

Sitz der Gesellschaft: Köln | Amtsgericht Köln: HRA 29646
Geschäftsführer: Stephan Dühr, M. Außendorf,
J. Steffens, P. Storz, M. v. Wieringen

Stephan Dühr

unread,
Dec 16, 2015, 1:15:50 PM12/16/15
to bareos...@googlegroups.com
On 12/16/2015 09:25 AM, Philipp Storz wrote:
> Hello,
>
> On 15.12.2015 22:38, Udo Claushues wrote:
>>
>> Hi,
>>
>> I use bareos for my backup at home.
>>
>> To save energy, i'd like to shutdown the server after the backup of the bareos catalog (last job).
>>
>> How can i shutdown the server?
>>
>> When i add this RunAfterJob command in bareos-dir.conf:
>>
>> RunAfterJob = "/sbin/poweroff"
>
> This is executed by the director, and that runs as user bareos.
>
> Try
> "Client Run After Job"
>
> as this is executed by the fd and it runs as root.
>

yes, and if the system is using systemd, I'd rather delay it by one minute
by using

Client Run After Job = "sh -c '/sbin/shutdown --poweroff +1'"

because systemd is doing the shutdown quite harshly and you'd get
errors when doing an immediate poweroff.



>>
>>
>> I get the following error: ... AfterJob: shutdown: Need to be root
>>
>>
>>
>>
>>
>>
>>
>
>


--
Stephan Dühr stepha...@bareos.com
Bareos GmbH & Co. KG Phone: +49 221-630693-90
http://www.bareos.com

Sitz der Gesellschaft: Köln | Amtsgericht Köln: HRA 29646
Komplementär: Bareos Verwaltungs-GmbH
Geschäftsführer: S. Dühr, M. Außendorf,
J. Steffens, Philipp Storz, M. v. Wieringen

Udo Claushues

unread,
Dec 16, 2015, 3:15:31 PM12/16/15
to bareos-users

Hi Stephan and hi Phillip,

many thanks for your help.

I've added:

Client Run After Job = "sh -c '/sbin/shutdown -h +1'"

to the backup-catalog job in bareos-dir.conf

And it works perfectly.

Now i can start the backupserver by the RTC (Bios) and it will shutdown when the last job is finished. Absolutely brilliant!

Greetings

Udo

Bruno Friedmann

unread,
Dec 17, 2015, 1:38:45 PM12/17/15
to bareos...@googlegroups.com
You're tryng to run the command on the server, -dir and so use bareos user account.

Try the same but with the configuration run on client (you normally have a -fd configured
also on the server).
Most of the time the -fd run as root so your command will be executed.
I would always let 5 to 10 minutes after the last backup to be sure
all activity has settle down.

--

Bruno Friedmann
Ioda-Net Sàrl www.ioda-net.ch

openSUSE Member & Board, fsfe fellowship
GPG KEY : D5C9B751C4653227
irc: tigerfoot

Reply all
Reply to author
Forward
0 new messages