Scheduled Restore?

457 views
Skip to first unread message

stephan...@posteo.de

unread,
Apr 22, 2016, 4:19:40 AM4/22/16
to bareos...@googlegroups.com
Hi everybody,

is it possible to do a scheduled restore of the latest backup of a
certain backup job?
I know - your documentation says: "No"
(http://www.bacula.org/5.1.x-manuals/en/main/main/Restore_Command.html)
But maybe there is a way scripting something like this?

Thanks a lot and many greets
Stephan

Philipp Storz

unread,
Apr 22, 2016, 4:21:10 AM4/22/16
to bareos...@googlegroups.com

Please refer to the bareos documentation. What is this bacula you are talking about?
--
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...@posteo.de

unread,
Apr 22, 2016, 4:29:41 AM4/22/16
to Bareos users
Am 22.04.2016 10:21 schrieb Philipp Storz:
> Please refer to the bareos documentation. What is this bacula you are
> talking about?

oh - I'm so embarrassed... ;-( Of course I meant this one:
http://doc.bareos.org/master/html/bareos-manual-main-reference.html#x1-17800016

Sorry and greets
Stephan

Philipp Storz

unread,
Apr 22, 2016, 4:31:46 AM4/22/16
to bareos...@googlegroups.com

You can give the restore command all things in one line: e.g.:

restore client=<client> fileset=<fileset> restoreclient=<client> \
where=/tmp/bareos-restores select all done

You only need to give this command to bconsole and it will restore.

stephan...@posteo.de

unread,
Apr 22, 2016, 6:00:13 AM4/22/16
to Bareos users
Hi Philipp

> You can give the restore command all things in one line: e.g.:
>
> restore client=<client> fileset=<fileset> restoreclient=<client> \
> where=/tmp/bareos-restores select all done
>
> You only need to give this command to bconsole and it will restore.

that helped a lot, thanks!
I know created a script that looks like this:

bconsole <<END_OF_DATA
restore client=someclient-fd restoreclient=someotherclient-fd select
current all where=/path/to/restore
done
yes
quit
END_OF_DATA

Unfortunately that doesn't fit my needs exactly, because on
someclient-fd we run two different backup jobs - one of them ist
executed daily, and the other one is executed hourly. I like to restore
the latest backup of the daily backup job. The above example restores
the current job of the client - which is mostly one of the hourly jobs.
:-(
Is it possible to put a job name into the script instead of (or
additionally to) a client name?

Thanks and greets
Stephan

Franck Ratier

unread,
Apr 22, 2016, 5:18:16 PM4/22/16
to bareos-users, stephan...@posteo.de
Yes you can do it but that requires a bit more bash scripting, you'll need at least to pipe commands to bconsole to get the arguments to build the restore command (i.e. the jobid) you want and then do something like:

bconsole <<-EOF
@output /dev/null
messages
@output
$BAREOS_RESTORE_COMMAND

messages
@output
EOF

With e.g. BAREOS_RESTORE_COMMAND="restore client=$CLIENT restoreclient=$RESTORE_CLIENT fileset=$FILESET pool=$POOL storage=$STORAGE jobid=${job_id//,/} select all done yes"

The parameter expansion on the jobid is useful for jobids>=1000.

Hope that helps.

Franck

Jörg Steffens

unread,
Apr 23, 2016, 6:10:21 AM4/23/16
to bareos...@googlegroups.com
Am 22.04.2016 um 23:18 schrieb Franck Ratier:
> Yes you can do it but that requires a bit more bash scripting, you'll
> need at least to pipe commands to bconsole to get the arguments to
> build the restore command (i.e. the jobid) you want and then do
> something like:
>
> bconsole <<-EOF @output /dev/null messages @output
> $BAREOS_RESTORE_COMMAND
>
> messages @output EOF
>
> With e.g. BAREOS_RESTORE_COMMAND="restore client=$CLIENT
> restoreclient=$RESTORE_CLIENT fileset=$FILESET pool=$POOL
> storage=$STORAGE jobid=${job_id//,/} select all done yes"
>
> The parameter expansion on the jobid is useful for jobids>=1000.
>
> Hope that helps.

if multiple bconsole commands are required, I prefer using
https://www.bareos.org/en/python-bareos.html, probably in JSON mode.

Required commands could be:

# get last successful job run of a specific job
list jobs job=BackupClient1 jobstatus=T last

result: jobid=X

# if this wasn't a full, get all jobids for a full restore
.bvfs_get_jobids jobid=X

Then trigger the restore with all jobids.

Jörg

--
Jörg Steffens joerg.s...@bareos.com
Bareos GmbH & Co. KG Phone: +49 221 630693-91
http://www.bareos.com Fax: +49 221 630693-10

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örg Steffens, P. Storz, M. v. Wieringen

Toon Meynen

unread,
Dec 5, 2017, 5:39:22 AM12/5/17
to bareos-users
This worked for me. It selects the latest successful job (FILESET)

```
CLIENT=FROM_CLIENT
RESTORE_CLIENT=TO_CLIENT
FILESET="DAILY_BACKUP"

BAREOS_RESTORE_COMMAND="restore client=$CLIENT restoreclient=$RESTORE_CLIENT fileset="${FILESET}" where=/tmp/bareos-restores select current all done yes"

bconsole <<EOF
@output /dev/null
messages
@tee /tmp/log_restore_db.out
$BAREOS_RESTORE_COMMAND
messages
@output
quit
EOF
```

Reply all
Reply to author
Forward
0 new messages