On 08/09/2018 01:59 PM, Bill Arlofski wrote:
> Hi Steve,
> 
> There is a "comment" field in the db for media table.  This might be useful
> for your case.
> 
> 
> In bconsole, you can:
> 
> * update volume=xxxxx comment="Files restored from this volume on 20180809"
> 
> can also be scripted: (sorry, will wrap in email)
> 
> echo "update volume=xxxxx comment=\"Files restored from this volume on
> 20180809\"" | bconsole
> 
> 
> Hope this helps,
> 
> Bill


Hi Steve,

This question was interesting to me so it motivated me to start writing a nice
how-to and a script to do this automatically after a restore job. ;)

I instantly ran into the fact that the bconsole "update volume" command does
not seem to accept comment="xxxxxx" for a volume in the same way a run job=xxx
comment="yyyy zzzz"  does.


I will make a feature request for this - both for the Community version and
internally for the Bacula Enterprise version.


But... In the mean time I am 99% finished with a nice automated way that will
allow you to:
- Run a restore job
- Automatically call my shell script in a Runscript { RunsWhen = After }
  stanza of the restore job
- The script checks to see if the restore job terminated "Restore OK" because
this is
  (RunsOnFail=no would make this additional check unnecessary of course :)
- If the Restore job was OK, then the script will determine the volumes that
  were read during the restore
- Next, with this list of volumes, it will check each volume to see if it has
  a comment already.
  - If no, it will just add a new comment like:
    "A test restore from this volume was done ${now} using restore jobid xxxx"
  - If yes, it will append the new comment to the current comment

Now, there is one other minor issue I am dealing with and that is when using
bconsole's "sql" command to add the comment, it seems like it is sanitizing
the input because I cannot seem to insert a line feed so that comments look
nice like:

----8<----
A test restore from this volume was done 20180810195703 with restore jobid 100
A test restore from this volume was done 20180810195714 with restore jobid 101
----8<---

Instead, I have to currently just append/separate each additional comment with
a " **** " so it looks like:
----8<----
A test restore from this volume was done 20180810195703 with restore jobid 100
**** A test restore from this volume was done 20180810195714 with restore
jobid 101 **** A test restore from this volume was done 20180810195809 using
restore jobid 102 ****
----8<----

Currently not pretty, but the important information is retained in the comment. 
:)

I could easily just use direct database 'psql' or 'mysql' commands, but I'd
rather keep this simple and just use bconsole for all the modifications to the
db in this case - hence the feature request for the "comment=" option for the
"update volume" command too. ;)


This script just needs a little bit of clean-up and some error checking added
and I will release it ASAP.


Hope this helps!

Bill

-- 
Bill Arlofski
http://www.revpol.com/bacula
-- Not responsible for anything below this line --

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Bacula-users mailing list
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users

Reply via email to