X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fexamples%2Fsample-query.sql;h=5863713d38a90c718fe56aad19e01178d075184e;hb=595c506509648b24da32b10a93c118abe969b718;hp=69ab59da0df34ada8d5766002d5e8fdf3376ee3c;hpb=aa88bb65780c389f9a624b16afabad0d6301726a;p=bacula%2Fbacula diff --git a/bacula/examples/sample-query.sql b/bacula/examples/sample-query.sql index 69ab59da0d..5863713d38 100644 --- a/bacula/examples/sample-query.sql +++ b/bacula/examples/sample-query.sql @@ -2,7 +2,14 @@ # This file contains sample queries that you can possibly use in # your query.sql file. However, please note that these examples # are not supported. They may or may not work -- in fact, they may -# work with one SQL engine and not another. +# work with one SQL engine and not another. As a consequence, +# please do not submit bug reports on either query.sql or +# sample-query.sql +# +# If you find that they work for MySQL and not for PostgreSQL, +# then please send us a whole new file corrected for PostgreSQL +# and we will post it in the examples directory for everyone +# to use. # # 1 @@ -193,3 +200,43 @@ SELECT VolumeName AS Volume,VolMounts AS Mounts,VolErrors AS Errors, WHERE (VolErrors>0) OR (VolStatus='Error') OR (VolMounts>50) OR (VolStatus='Disabled') OR (VolWrites>3999999) ORDER BY VolStatus ASC, VolErrors,VolMounts,VolumeName DESC; +# 17 +:List Volumes Bacula thinks are eligible for the changer +SELECT VolumeName,VolStatus,Storage.Name AS Location, + VolBytes/(1024*1024*1024) AS GB,MediaId,MediaType,Pool.Name AS Pool + FROM Media,Pool,Storage + WHERE Media.PoolId=Pool.PoolId + AND Media.StorageId=Storage.StorageId + AND InChanger=0 + AND ((VolStatus='Purged') OR (VolStatus='Append') OR (VolStatus='Recycle')) + ORDER BY VolMounts ASC, Pool.Name ASC, VolumeName ASC +# 18 +:List Volumes by Volume: +SELECT VolumeName, Job.JobId as JobID, Job.Name as JobName, Job.StartTime as +Start, sum(JobFiles) AS Files,sum(JobBytes) AS Bytes + FROM Job,JobMedia,Media + WHERE JobMedia.JobId=Job.JobId + AND JobMedia.MediaId=Media.MediaId + GROUP by VolumeName, Job.JobID, Job.Name, Job.StartTime + ORDER by VolumeName; +# 19 +:List Volumes by Jobs: +SELECT Job.Name as JobName, Job.JobId as JobID, VolumeName, Job.StartTime as +Start, sum(JobFiles) AS Files,sum(JobBytes) AS Bytes + FROM Job,JobMedia,Media + WHERE JobMedia.JobId=Job.JobId + AND JobMedia.MediaId=Media.MediaId + GROUP by VolumeName, Job.JobID, Job.Name, Job.StartTime + ORDER by JobName, Start; +# 20 +:List Volumes for a jobname: +*Enter Job name: +SELECT Job.Name as JobName, Job.JobId as JobID, VolumeName, Job.StartTime as +Start, sum(JobFiles) AS Files,sum(JobBytes) AS Bytes + FROM Job,JobMedia,Media + WHERE Job.Name='%1' + AND JobMedia.JobId=Job.JobId + AND JobMedia.MediaId=Media.MediaId + GROUP by VolumeName, Job.JobID, Job.Name, Job.StartTime + ORDER by JobName, Start; +