Forum Discussion

DPeaco's avatar
DPeaco
Moderator
5 months ago

Why So Hard To Do A Report for MSSQL Backups?

Greetings,
I've been trying to get a good report out of nbuita for MSSQL backups and I get some but I'm missing a log of backups that are directly related to Availability Group Backups. I was given some sql code from a Veritas person but I'm not able to hack the code to get what I'm after. 
I checked the nbuita reports library and guess what....there are No Reports for MS-SQL backup policy type.
No, I do not know Oracle SQL code. Yes I use Google searches and yes, I ask other people but I end up with ZERO answers.

Because of all these reporting problems, we are looking at moving to a different vendor. I'll just leave this where it sits.

11 Replies

  • Hi Dennis,

    Please send an email to mailto:ernie.bergan@cohesity.com and I will send you a pair of reports to evaluate.  For some reason I can't attach them here.

    When you get the templates:  Scoring for a requested time period summarizes the best outcome achieved (e.g. if the day had both successes and warnings, the summary will be a success). 

    To get the drilldown working on your portal, you’ll probably need to do the following:

    Run the drilldown report directly.  It will return no rows.  While on the drilldown report, press Ctrl+ALT+T  .   Note the number in the highlighted example:

     

     

     

    Customize the NBU SQL Server DB Summary_v5 template.  Select the formatting tab, click on the Summary row, and then the Advanced button at the bottom of the popup.

     

    Edit the Drilldown, setting the templateID to the template ID of the drilldown.

     

  • Ok, here's the result of the joint effort of ZenOfAnalytics and me:

    And the Query code that does include my modifications to get the result I need to send out to my MS-SQL DBA Team:

    -- Author:  ernie.bergan@veritas.com
    -- Last Modified 2022/09/16

    -- Configured to be a stand alone template rather than a drilldown target.

    --
    -- Added Schedule level

    -- Previously Modified:  2022/05/20
    -- Added date ranging logic and additional hidden fields to help guide drilldowns
    -- Previously Modified:   2022/04/27
    --
    -- Summarizes best status achieved for MSSQL policies per user-specified time period.
    -- Default grouping is per day, based on job start time.
    -- Jobs that don't resolve to a SQL Server DB name are ignored.
    -- Order is client_name, instance name, DB name, period (date)
    --
    WITH jobs AS (
        SELECT
            server_id,
            job_id,
            policy_id,
            policy_name,
            job_type_name,
            schedule_name,
            schedule_type_name,
            summary_status,
            vendor_status_name,
            client_id,
            client_host_name,
            nbu_job_id,
            parent_nbu_job_id,
            start_date,
            finish_date
        FROM
            apt_v_nbu_job_detail
        WHERE
            client_host_name NOT LIKE 'nbunpamas01'
            AND policy_type=15 --policy_type_name LIKE 'MS-SQL%'
            AND  start_date BETWEEN ${startDate} AND ${endDate} --start_date between sysdate - 90 and sysdate  
            AND client_id in (${hosts})
            AND job_type NOT IN (107)

    ), paths AS (
        SELECT
            j.server_id,
            j.job_id,
            j.policy_id,
            j.policy_name,
            j.job_type_name,
            j.schedule_type_name,
            j.summary_status,
            j.vendor_status_name,
            j.client_id,
            j.client_host_name,
            NVL(dbi.instance_name,'none') instance_name,
            j.nbu_job_id,
            j.parent_nbu_job_id,
            j.start_date,
            j.finish_date,
            jf.job_id job_file_job_id,
            jf.pathname
        FROM
            apt_v_nbu_job_file jf,
            jobs               j,
            apt_v_nbu_policy_db_instance dbi
        WHERE
            j.job_id = jf.job_id (+)
            AND j.policy_id = dbi.policy_id (+)
    )
    --select * from paths;
    , dbname AS ( /*+NO_MERGE(paths)*/
        SELECT 
            server_id,
            client_id,
            client_host_name,
            job_id,
            policy_id,
            policy_name,
            job_type_name,
            --schedule_name,
            schedule_type_name,
            instance_name,
            CASE
                WHEN instr(pathname, 'trx') > 0  THEN
                    TRIM('/' FROM TRIM('.' FROM substr(pathname, instr(pathname, 'trx') + 3, instr(pathname, '~') - 1 - instr(pathname, 'trx') -
                    2)))
                WHEN instr(pathname, 'inc') > 0  THEN
                    TRIM('/' FROM TRIM('.' FROM substr(pathname, instr(pathname, 'inc') + 3, instr(pathname, '~') - 1 - instr(pathname, 'inc') -
                    2)))
                WHEN instr(pathname, '.md.') > 0 THEN
                    TRIM('/' FROM TRIM('.' FROM substr(pathname, instr(pathname, '.md.') + 4, instr(pathname, '~') - 1 - instr(pathname, '.md.') -
                    3)))
                WHEN instr(pathname, '/md/') > 0 THEN
                    TRIM('/' FROM TRIM('.' FROM substr(pathname, instr(pathname, '/md/') + 4, instr(pathname, '~') - 1 - instr(pathname, '/md/') -
                    3)))
                WHEN instr(pathname, '.db.') > 0 THEN
                    TRIM('/' FROM TRIM('.' FROM substr(pathname, instr(pathname, '.db.') + 4, instr(pathname, '~') - 1 - instr(pathname, '.db.') -
                    3)))
                WHEN instr(pathname, '/db/') > 0 THEN
                    TRIM('/' FROM TRIM('.' FROM substr(pathname, instr(pathname, '/db/') + 4, instr(pathname, '~') - 1 - instr(pathname, '/db/') -
                    3)))
                WHEN instr(pathname, 'DATABASE="') > 0
                     AND instr(pathname, 'DATABASE="%24ALL"') = 0 THEN
                    TRIM('/' FROM TRIM('.' FROM substr(pathname, instr(pathname, 'DATABASE="') + 10, instr(pathname, ';TYPE=') - 1 - instr(
                    pathname, 'DATABASE="') - 10)))
            END db_name,
            -- instance_name,
            nbu_job_id,
            parent_nbu_job_id,
            start_date,
            finish_date,
            summary_status,
            vendor_status_name
        FROM
            paths
    )
    select 
    dbname.* 
    FROM dbname
    where db_name is not null
    ORDER BY client_host_name,start_date,db_name

    -- Author:  ernie.bergan@veritas.com
    -- Last Modified 2022/09/16

    -- Configured to be a stand alone template rather than a drilldown target.

    --
    -- Added Schedule level

    -- Previously Modified:  2022/05/20
    -- Added date ranging logic and additional hidden fields to help guide drilldowns
    -- Previously Modified:   2022/04/27
    --
    -- Summarizes best status achieved for MSSQL policies per user-specified time period.
    -- Default grouping is per day, based on job start time.
    -- Jobs that don't resolve to a SQL Server DB name are ignored.
    -- Order is client_name, instance name, DB name, period (date)
    --
    WITH jobs AS (
        SELECT
            server_id,
            job_id,
            policy_id,
            policy_name,
            job_type_name,
            schedule_name,
            schedule_type_name,
            summary_status,
            vendor_status_name,
            client_id,
            client_host_name,
            nbu_job_id,
            parent_nbu_job_id,
            start_date,
            finish_date
        FROM
            apt_v_nbu_job_detail
        WHERE
            client_host_name NOT LIKE 'nbmasterservername'
            AND policy_type=15 --policy_type_name LIKE 'MS-SQL%'
            AND  start_date BETWEEN ${startDate} AND ${endDate} --start_date between sysdate - 90 and sysdate  
            AND client_id in (${hosts})
            AND job_type NOT IN (107)

    ), paths AS (
        SELECT
            j.server_id,
            j.job_id,
            j.policy_id,
            j.policy_name,
            j.job_type_name,
            j.schedule_type_name,
            j.summary_status,
            j.vendor_status_name,
            j.client_id,
            j.client_host_name,
            NVL(dbi.instance_name,'none') instance_name,
            j.nbu_job_id,
            j.parent_nbu_job_id,
            j.start_date,
            j.finish_date,
            jf.job_id job_file_job_id,
            jf.pathname
        FROM
            apt_v_nbu_job_file jf,
            jobs               j,
            apt_v_nbu_policy_db_instance dbi
        WHERE
            j.job_id = jf.job_id (+)
            AND j.policy_id = dbi.policy_id (+)
    )
    --select * from paths;
    , dbname AS ( /*+NO_MERGE(paths)*/
        SELECT 
            server_id,
            client_id,
            client_host_name,
            job_id,
            policy_id,
            policy_name,
            job_type_name,
            --schedule_name,
            schedule_type_name,
            instance_name,
            CASE
                WHEN instr(pathname, 'trx') > 0  THEN
                    TRIM('/' FROM TRIM('.' FROM substr(pathname, instr(pathname, 'trx') + 3, instr(pathname, '~') - 1 - instr(pathname, 'trx') -
                    2)))
                WHEN instr(pathname, 'inc') > 0  THEN
                    TRIM('/' FROM TRIM('.' FROM substr(pathname, instr(pathname, 'inc') + 3, instr(pathname, '~') - 1 - instr(pathname, 'inc') -
                    2)))
                WHEN instr(pathname, '.md.') > 0 THEN
                    TRIM('/' FROM TRIM('.' FROM substr(pathname, instr(pathname, '.md.') + 4, instr(pathname, '~') - 1 - instr(pathname, '.md.') -
                    3)))
                WHEN instr(pathname, '/md/') > 0 THEN
                    TRIM('/' FROM TRIM('.' FROM substr(pathname, instr(pathname, '/md/') + 4, instr(pathname, '~') - 1 - instr(pathname, '/md/') -
                    3)))
                WHEN instr(pathname, '.db.') > 0 THEN
                    TRIM('/' FROM TRIM('.' FROM substr(pathname, instr(pathname, '.db.') + 4, instr(pathname, '~') - 1 - instr(pathname, '.db.') -
                    3)))
                WHEN instr(pathname, '/db/') > 0 THEN
                    TRIM('/' FROM TRIM('.' FROM substr(pathname, instr(pathname, '/db/') + 4, instr(pathname, '~') - 1 - instr(pathname, '/db/') -
                    3)))
                WHEN instr(pathname, 'DATABASE="') > 0
                     AND instr(pathname, 'DATABASE="%24ALL"') = 0 THEN
                    TRIM('/' FROM TRIM('.' FROM substr(pathname, instr(pathname, 'DATABASE="') + 10, instr(pathname, ';TYPE=') - 1 - instr(
                    pathname, 'DATABASE="') - 10)))
            END db_name,
            -- instance_name,
            nbu_job_id,
            parent_nbu_job_id,
            start_date,
            finish_date,
            summary_status,
            vendor_status_name
        FROM
            paths
    )
    select 
    dbname.* 
    FROM dbname
    where db_name is not null
    ORDER BY client_host_name,start_date,db_name
    ----end code query here------

    And the result looks like this:

     

    • DPeaco's avatar
      DPeaco
      Moderator

      Hello Ernie,
      No drill down needed here. This is a straight report being sent out to the MS SQL DBA's.
      Report every day - to reflect the previous 24 hours of MS SQL Backups.
      Report every Monday morning - to reflect on the previous 7 days of MS SQL Backups.

      The report should include any MS SQL backups performed until the MS-SQL Server backup policy type - no matter if the backup is for db's not in an Availability Group as well as db's that ARE in an Availability Group.

      The report should reflect the correct backup start time and the correct backup end time and not report everything starting and finishing at or near mid-night each day. It's like NBUITA doesn't like crossing days since it seems to love reporting on 00:00:00 to 23:59:59 of the same day....even though a backup runs for 68 hours...the report still reflects that it ran in 24 hours.

  • ZenOfAnalytics​ are these templates accessible by public?!I I suggest you try to have it available here for other people, who are looking for such templates, as most of us are not aware about analyzing /writing cods which is required with NBA.

    • DPeaco's avatar
      DPeaco
      Moderator

      --
      WITH vrs as (
        select '${instance}' as the_instance,
               '${dbname}' as the_DBname,
               '${summstatus}' as the_summ_status
      FROM apt_v_dual
      )
      --Select the_instance, the_DBname, the_summ_status from vrs
      ,jobs AS (
          SELECT
              server_id,
              job_id,
              policy_id,
              policy_name,
              job_type_name,
              schedule_name,
              schedule_type_name,
              summary_status,
              vendor_status_name,
              client_id,
              client_host_name,
              nbu_job_id,
              parent_nbu_job_id,
              start_date,
              finish_date
          FROM
              apt_v_nbu_job_detail,vrs
          WHERE
              policy_type_name LIKE 'MS-SQL%'
              AND  start_date BETWEEN ${startDate} AND ${endDate} --start_date between sysdate - 90 and sysdate  --
              AND client_id = ${clientIds}
              AND summary_status >= the_summ_status
              AND job_type NOT IN (107)
      ), paths AS (
          SELECT
              j.server_id,
              j.job_id,
              j.policy_id,
              j.policy_name,
              j.job_type_name,
              j.schedule_type_name,
              j.summary_status,
              j.vendor_status_name,
              j.client_id,
              j.client_host_name,
              NVL(dbi.instance_name,'none') instance_name,
              j.nbu_job_id,
              j.parent_nbu_job_id,
              j.start_date,
              j.finish_date,
              jf.job_id job_file_job_id,
              jf.pathname
          FROM
              apt_v_nbu_job_file jf,
              jobs               j,
              apt_v_nbu_policy_db_instance dbi
          WHERE
              j.job_id = jf.job_id (+)
              AND j.policy_id = dbi.policy_id (+)
      )
      --select * from paths;
      , dbname AS ( /*+NO_MERGE(paths)*/
          SELECT 
              server_id,
              client_id,
              client_host_name,
              job_id,
              policy_id,
              policy_name,
              job_type_name,
              --schedule_name,
              schedule_type_name,
              instance_name,
              CASE
                  WHEN instr(pathname, 'trx') > 0  THEN
                      TRIM('/' FROM TRIM('.' FROM substr(pathname, instr(pathname, 'trx') + 3, instr(pathname, '~') - 1 - instr(pathname, 'trx') -
                      2)))
                  WHEN instr(pathname, 'inc') > 0  THEN
                      TRIM('/' FROM TRIM('.' FROM substr(pathname, instr(pathname, 'inc') + 3, instr(pathname, '~') - 1 - instr(pathname, 'inc') -
                      2)))
                  WHEN instr(pathname, '.md.') > 0 THEN
                      TRIM('/' FROM TRIM('.' FROM substr(pathname, instr(pathname, '.md.') + 4, instr(pathname, '~') - 1 - instr(pathname, '.md.') -
                      3)))
                  WHEN instr(pathname, '/md/') > 0 THEN
                      TRIM('/' FROM TRIM('.' FROM substr(pathname, instr(pathname, '/md/') + 4, instr(pathname, '~') - 1 - instr(pathname, '/md/') -
                      3)))
                  WHEN instr(pathname, '.db.') > 0 THEN
                      TRIM('/' FROM TRIM('.' FROM substr(pathname, instr(pathname, '.db.') + 4, instr(pathname, '~') - 1 - instr(pathname, '.db.') -
                      3)))
                  WHEN instr(pathname, '/db/') > 0 THEN
                      TRIM('/' FROM TRIM('.' FROM substr(pathname, instr(pathname, '/db/') + 4, instr(pathname, '~') - 1 - instr(pathname, '/db/') -
                      3)))
                  WHEN instr(pathname, 'DATABASE="') > 0
                       AND instr(pathname, 'DATABASE="%24ALL"') = 0 THEN
                      TRIM('/' FROM TRIM('.' FROM substr(pathname, instr(pathname, 'DATABASE="') + 10, instr(pathname, ';TYPE=') - 1 - instr(
                      pathname, 'DATABASE="') - 10)))
              END db_name,
              nbu_job_id,
              parent_nbu_job_id,
              start_date,
              finish_date,
              summary_status,
              vendor_status_name
          FROM
              paths
      )
      select --vrs.the_instance, vrs.the_DBname, 
      dbname.* 
      FROM dbname, vrs
      WHERE instance_name = the_instance 
            AND db_name = the_DBname

    • DPeaco's avatar
      DPeaco
      Moderator

      kiyan​ 
      Please don't ask me what any of the posted SQL code means....it took me 2 months to figure out the old code from the previous SQL Template.  My boss was not happy that it took me that long but....I'm a backup admin....not a DBA writing SQL queries

      The above code is under a report named: NBU SQLServer DB Detail_v5

      I am VERY GRATEFUL for Ernie's help on this......He truly IS.....The Zen Of Analytics

      • Robert_Geller's avatar
        Robert_Geller
        Level 5

        keep in mind, that SQL alone wont work in RTD/SQL template designer without setting up the components in the Template Designer tab (as needed)

        ZenOfAnalytics​ (Ernie) is a Great.  He taught me everything I know  about ITA ;-)

         

         

    • DPeaco's avatar
      DPeaco
      Moderator

      kiyan​ 

      There are some videos on YouTube that I used to help me through some situations in NBUITA. These are the videos that I used on YT:
      https://youtube.com/playlist?list=PLvB9eddv7kt7Dw9BQ9zX5AHaK5-QMOh8f&si=soxLXikWp9iHPrqf

  • ZenOfAnalytics​ 
    is there a way to show the scheduled activity which are finished and show the missed scheduled as well,for example, currently in the template each schedule is showing in a separate row, but let say if I want to get a report for each day or a week, of all SQL backups that happen, which were successful or not successful or did not happen at all (kind of like check mark , or specific color for reach schedule name),
    the reason I am asking, we have logs backup happening every 1 hour, it will make it very difficult to spot if any schedule did not happen at all.