On 08/09/2018 04:13 AM, Adam Weremczuk wrote:
> Hi all,
>
> What's the best way to read Bacula label of a currently mounted tape directly
> from bash?
>
> In our environment I can fairly reliably determine it with:
>
> tail -1 /var/lib/bacula/log
> 08-Aug 14:19 bacula_dir JobId 0: Recycled volume "LTO-W20110914A"
>
> but ideally I would prefer Bacula to report the current actual state.
>
> I'm aware of bconsole, btape etc. but they are all interactive consoles.
>
> I think it's possible to query Bacula database (MySQL in my case).
>
> Any neat "one line" suggestions?
>
> Thanks,
> Adam
Hi Adam... Here is a neat one line suggestion what shows you some information
about all the jobs running on an SD - including the volume mounted.
----8<----
#!/bin/bash
watch -tn 1 'echo -e "Monitoring XXXX Storage\n"; \
echo -e "status storage=XXXX\nquit\n" \
| bconsole \
| awk "BEGIN {IGNORCASE=1;} /^Running.*/,/^====$/ {print}" \
| grep -A4 "^Writing" \
| grep "^Writing:\|^ \+pool=\|^ \+Files=" \
| sed "s/\(Files=.*\)/\1\n/"'
----8<----
In my environment, I have two separate storages, and so I have two panes in
tmux running this script in each pane so when backup jobs are running, the
panes are continually updated.
Sample output with two jobs running:
----8<----
Monitoring Speedy Storage
Writing: Full Backup job dns1 JobId=24684 Volume="c0_0001_0061"
pool="Offsite-eSATA-Full" device="speedy_drv_1" (/vchanger/speedy-file/1)
Files=13,157 Bytes=228,019,136 AveBytes/sec=835,234 LastBytes/sec=725,425
Writing: Full Backup job dns2 JobId=24685 Volume="c0_0001_0005"
pool="Offsite-eSATA-Full" device="speedy_drv_0" (/vchanger/speedy-file/0)
Files=2,995 Bytes=62,401,227 AveBytes/sec=751,822 LastBytes/sec=572,665
----8<----
Not exactly what you are looking for, but I find this to be quite useful here.
If you only wanted the volume name then:
----8<----
echo "status storage=speedy-file" \
| bconsole \
| grep "Volume=" \
| cut -d= -f3 \
| tr -d \"
----8<----
Which currently outputs:
----8<----
c0_0001_0061
c0_0001_0005
----8<----
Hope some of this is helpful.
Best regards,
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/bacula-users