Backup Jobs Extra Informations #11
heitorfaria
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello Bill,
Please also consider including the following information options.
`[root@ebacula bin]# ./report_jobs 1
Report Bacula Jobs Last 1 Day(s)
Sun Oct 22 08:14:35 AM CDT 2023
ebacula-fd 0.00
pg_restore-fd
teste-fd
debian-fd
rescue-fd
linux-fd
windows-entrenamiento-fd
proxmox-fd
oracledb-fd
proxmox2-fd
zimbra-fd
windows-fd
debian11-fd
ebacula-fd
qnap01 22.03
dedup1 15.86
dedup2 0.01
tape 0.00
exagrid_a 126.60
Script
`#!/bin/bash
Report Bacula
Interval, in days
d=$1
lic=200
hostname=$(hostname)
jobst=$(sudo -u bacula psql -c "SELECT COUNT() AS job_count FROM job WHERE type = 'B' AND jobstatus = 'T' AND endtime >= NOW() - interval '$d day';" | sed -n '3,3p' | sed 's/ //g')
jobsf=$(sudo -u bacula psql -c "SELECT COUNT() AS job_count FROM job WHERE type = 'B' AND jobstatus = 'f' AND endtime >= NOW() - interval '$d day';" | sed -n '3,3p' | sed 's/ //g')
jobse=$(sudo -u bacula psql -c "SELECT COUNT() AS job_count FROM job WHERE type = 'B' AND jobstatus = 'e' AND endtime >= NOW() - interval '$d day';" | sed -n '3,3p' | sed 's/ //g')
sized=$(sudo -u bacula psql -c "SELECT ROUND(SUM(jobbytes) / (1024^3)::numeric, 2) as total_gigabytes FROM job WHERE type = 'B' AND endtime >= NOW() - interval '$d day';" | sed -n '3,3p' | sed 's/ //g')
sizec=$(sudo -u bacula psql -c "SELECT c.name AS client_name, ROUND(SUM(CAST(j.jobbytes AS NUMERIC) / (1024^3)::NUMERIC), 2) AS jobbytes_in_gigabytes FROM client c JOIN job j ON c.clientid = j.clientid WHERE j.endtime >= NOW() - interval '$d day' GROUP BY c.name;" | grep "|" | grep -v client_name | sed 's/ //g' | sed 's/^/ /g' | sed 's/|/ /g')
restt=$(sudo -u bacula psql -c "SELECT COUNT() AS job_count FROM job WHERE type = 'R' AND jobstatus = 'T' AND endtime >= NOW() - interval '$d day';" | sed -n '3,3p' | sed 's/ //g')
reste=$(sudo -u bacula psql -c "SELECT COUNT(*) AS job_count FROM job WHERE type = 'R' AND jobstatus = 'e' AND endtime >= NOW() - interval '$d day';" | sed -n '3,3p' | sed 's/ //g')
sizer=$(sudo -u bacula psql -c "SELECT ROUND(SUM(jobbytes) / (1024^3)::numeric, 2) as total_gigabytes FROM job WHERE type = 'R' AND endtime >= NOW() - interval '$d day';" | sed -n '3,3p' | sed 's/ //g')
lcli=$(sudo -u bacula psql -c "select name from client;" | head -n -2 | grep -v -e name -e "------" | sed 's/ //g' | sed 's/^/ /g' | sed 's/|/ /g')
stocup=$(sudo -u bacula psql -c "SELECT s.name AS storage_name, ROUND(SUM(m.volbytes) / 1073741824.0, 2)::TEXT || '' AS total_volbytes_gb FROM media AS m JOIN storage AS s ON m.storageid = s.storageid GROUP BY s.name;" | head -n -2 | tail -n +3 | sed 's/^ / /g' | sed 's/|/ /g')
cli=$(sudo -u bacula psql -c "select count(distinct ClientId) from Client;" | sed -n '3,3p' | sed 's/ //g')
vm=$(sudo -u bacula psql -c "SELECT count(distinct Filename) FROM File JOIN Path USING (PathId) where Path.Path LIKE '/@vsphere/';" | sed -n '3,3p' | sed 's/ //g')
agents=$(expr $cli + $vm)
size=$(sudo -u bacula psql -c "SELECT ROUND(SUM(jobbytes) / (1024^3)::numeric, 2) as total_gigabytes FROM job WHERE type = 'B';" | sed -n '3,3p' | sed 's/ //g')
sizee=$(sudo -u bacula psql -c "SELECT ROUND(SUM(volbytes) / 1073741824.0, 2) AS total_volbytes_gb FROM media WHERE volstatus IN ('Purged', 'Recycled');" | sed -n '3,3p' | sed 's/ //g')
jobmedia=$(sudo -u bacula psql -c "SELECT m.volumename, (SELECT j.job FROM job AS j WHERE j.jobid = jm.jobid) AS job FROM media AS m JOIN jobmedia AS jm ON m.mediaid = jm.mediaid WHERE m.lastwritten > NOW() - INTERVAL '$d day';" | grep "|" | grep -v volumename | sed 's/ //g' | sed 's/^/ /g' | sed 's/|/ /g')
echo "========================================================================================================"
echo "Report Bacula Jobs Last $d Day(s)"
date
echo "========================================================================================================"
echo "1. Backups OK last $d days $jobst"
echo "2. Backups with Fails last $d days $jobsf"
echo "3. Failed Backups last $d days $jobse"
echo "4. Backed up data (GB) last $d days $sized"
echo "5. Backed up data per client (GB)"
echo "$sizec"
echo "6. Restores OK $restt"
echo "7. Failed Restores $reste"
echo "8. Restores Size (GB) $sizer"
echo "9. Configured Backup Clients"
echo "$lcli"
echo "10. Storages Occupation"
echo "$stocup"
echo "11. Used/Total Licenses $agents/$lic"
echo "12. Total Protected Data (GB) $size"
echo "13. Total Expired Data (GB) $sizee"
echo "14. Volume Jobs"
echo "$jobmedia"
echo "======================================================================================================="
`
Rgds.
Beta Was this translation helpful? Give feedback.
All reactions