Need a Script to check Database backup chain for revovery

Dear All,
any having a handy script to check database backup chain ,
Database A --> Full backup  -- Diff -- log1 --Log 2 ...... and scan through the files to validate if we can recover the database using the avaiable backups.
Regards
Sufian
Mohd Sufian www.sqlship.wordpress.com Please mark the post as Answered if it helped.

You can use below TSQL
set nocount on
go
if exists ( select name from tempdb..sysobjects where name like '#DatabasesBackupsStatus%')
drop table #DatabasesBackupsStatus
GO
create table #DatabasesBackupsStatus
ServerName varchar(100) null,
DBName varchar(100) null,
RecoveryModel varchar(100) null,
LastFullbackup datetime null,
days_since_Lastfullbackup int null,
days_since_Lastdiffbackup int null,
HOURS_since_LastLogbackup int,
DBStatus varchar (100) null,
FullBackupLocation varchar(1000) null,
MEDIASET INT,
JobOwner varchar(100) null
Go
insert into #DatabasesBackupsStatus(ServerName,DBName)
select convert(varchar,serverproperty('ServerName')),a.name
from master.dbo.sysdatabases a
where a.name <> 'tempdb'
update #DatabasesBackupsStatus
set LastFullbackup=b.backup_start_date,
days_since_Lastfullbackup=datediff(dd,b.backup_start_date,getdate()),
MEDIASET=b.media_set_id
from #DatabasesBackupsStatus a,(select database_name,MAX(media_set_id)media_set_id,max(backup_start_date) backup_start_date
from msdb..backupset where type='D' group by database_name)b
where a.DBName=b.database_name
update #DatabasesBackupsStatus
set RecoveryModel=convert(sysname,DatabasePropertyEx(DBName,'Recovery'))
update #DatabasesBackupsStatus
set DBStatus=convert(sysname,DatabasePropertyEx(DBName,'Status'))
update d
set d.FullBackupLocation=b.physical_device_name
from #DatabasesBackupsStatus d , msdb..backupmediafamily b
where d.MEDIASET =b.media_set_id
update d
set d.days_since_Lastdiffbackup=datediff(dd,b.backup_finish_date,getdate())
from #DatabasesBackupsStatus d , (select database_name,max(backup_finish_date) backup_finish_date
from msdb..backupset where type ='I' group by database_name) b
where d.DBName = b.database_name
update d
set d.JobOwner=b.[user_name]
from #DatabasesBackupsStatus d , msdb..backupset b
where d.MEDIASET = b.media_set_id
update d
set d.HOURS_since_LastLogbackup=datediff(hh,b.backup_finish_date,getdate())
from #DatabasesBackupsStatus d , (select database_name,max(backup_finish_date) backup_finish_date
from msdb..backupset where type ='L' group by database_name) b
where d.DBName = b.database_name
AND d.RecoveryModel != 'SIMPLE'
Go
select * from #DatabasesBackupsStatus
Go
drop table #DatabasesBackupsStatus
Please Mark This As Answer if it solved your issue 
Please Mark This As Helpful if it helps to solve your issue
Thanks,
Shashikant

Similar Messages

  • Need a script to check the version of Office365 Pro Plus to push our office updates

    I need a script that could check the version of office365 pro plus e.g ( 15.0.4711.1002) and if it doesn't exists on users machine than to deploy a latest version from a network location
    I have an XML which works fine with downloading and even when deploying onto test machine but would not work on users which has an encrypted HDD and windows firewall turned on. the machine don't seem to pull the updates from Microsoft hence why wanted to
    deploy the updates through a GPO start-up script
    Currently the script would run the setup countless times without checking version and exiting the process if the version found. I hope the information given is adequate. Thanks

    Frederik, After some tweaking and testing i was able to get it working, I haven't tested it via GPO as a startup script but standalone it is doing what i was after. I cant thank you enough for helping me on this as i had lost hope after days worth of intense
    searching
    Change that i had to apply ( space in a network path
    was causing a "path not found error", Had to rename the "Office365 update" and update the path in Customconfig.xml  or any other location that was pointing to "office365 update" )
     set DeployServer=\\contoso\c2r\Office365 update\
    REM Set ConfigFile to the configuration file to be used for
    deployment (required)
    set ConfigFile=\\contoso\c2r\Office365 update\Customconfig.xml
    REM Set LogLocation to a central directory to collect script
    log files (install log files are set in XML file).
    set LogLocation=C:\AppData\Local\Temp

  • Scripts To Check Database Growth in Oracle 10g

    Hi All,
    I need your help developing a script to find out the database growth in Oracle 10G on daily, weekly and monthly basis.
    In our production database tablespace growth is huge and we are adding data files frequently. Management is asking about the database growth report and I need to present it. Is there any such script which will suffice the purpose.
    My database version is 10.2.0.5.
    Please help.
    Regards,
    Arijit

    1000103 wrote:
    Hi All,
    I need your help developing a script to find out the database growth in Oracle 10G on daily, weekly and monthly basis.
    In our production database tablespace growth is huge and we are adding data files frequently. Management is asking about the database growth report and I need to present it. Is there any such script which will suffice the purpose.
    only the report that you create
    How do I ask a question on the forums?
    SQL and PL/SQL FAQ

  • Need help scripting the Essentials Server Backup configuration in PowerShell

    I'm trying to write a PowerShell script that automates the setup and configuration of the Server Backup feature within WS2012 R2 Essentials. There are a number of cmdlets for defining the backup source files and target location such as add-wssbackuptarget,
    add-wssbackupvolume, new-wssbackuptarget, etc.
    These cmdlets all have a required -Disk parameter and I can't for the life of me figure out the syntax for it. I've tried the disk ID, drive letter, LUN, volume label, and disk number. All of the examples in the help files are using variables instead of
    explicitly entering a value; I've tried using the example scripts and those fail too.
    So here's a quick example:
    Get-WssBackupPolicy | Add-WssBackupVolume -Disk ??
    I obviously need more parameters than that but the point is, no matter what other parameters I type and no matter what I enter for the value of -Disk, I always get "Cannot bind parameter 'Disk'. Cannot convert the "D:\" (or whatever I've entered)
    value of "System.String" to type "Microsoft.WindowsServerSolutions.DataProtection.ServerBackup.ObjectModel.BackupDisk".
    And like I said in the opening paragraph, I get that same error for any and all cmdlets that use the -Disk parameter. Does anyone know how to properly structure format the -Disk value?
    Thanks

    Don't worry I wasn't sure as well, I had to raise a SR to understand it too!
    I have a similar set up to yours and have webutil working successfully.
    What you need to do is to install and configure your application server on unix for webutil as well as windows.
    From your post I see you are already reading the docs. Within chapters 2 and 3 both of which are titled "configuring web util", you will see points that refer to the application server, these are the ones that you need to follow.
    Good luck

  • Need to take SQL Azure database backup into blob using dacpac services, the blob has to be encrypted.

    We are able to take backup of our database into blob storage using dacpac services, but we need to encrypt the blob data. Please suggest the efficient way to do it.

    Hello,
    As per my understanding, Windows Azure Storage does not transparently encrypt data or provide any special encryption mechanisms. Azure Blob Storage protect the data by using a storage key to control access to all data in that Storage Account.
    If you want to encrypt data of file inside Azure Blob Storage Services , you can refer to the following thread about same requirement:
    http://social.msdn.microsoft.com/Forums/windowsazure/en-US/23465a1e-1fce-481a-b375-6e2434186ea6/encrypt-sql-azure-blob-data?forum=windowsazuredata#bf6c9921-176e-4c76-b976-3b94c795cd16
    Regards,
    Fanny Liu
    If you have any feedback on our support, please click here. 
    Fanny Liu
    TechNet Community Support

  • Script to check database connection on 9.3.1

    Hello,
    I hope I can describe this clearly. We are running Hyperion 9.3.1. The database and essbase are on one server, and the applications are on another server.
    We do a nightly database and essbase backup, and in some environments, we lose the database connection, as evidenced by signing onto EAS, and trying to access the Business Rules icon, and getting a message that the connection failed. We currently resolve this by scheduling a restart of the services, but I have been asked instead if I can write a script that queries the database, and if it is not up, to send an email.
    I am not an experienced script writer, and would appreciate as much help as I can get towards this objective. Thank you for reading this.

    Take a look at this thread: Re: Planning server not showing up while attaching BR in Essbase
    I just did a quick test on my 11.1.1.3 VM and ran this query:
    SELECT COUNT(*) FROM HBRPluginData
    If you didn't get at least a 1 as a response, you'd know it wasn't working.
    It wouldn't be all that hard to script it. An easy test is the next time EAS is down to go try the above query and prove that you get a 0 or an error and compare it to EAS in a running state.
    Regards,
    Cameron Lackpour

  • Need a Script to check 3 csv files

    Hi,
    Can someone help me with the Power Shell script with the below requirements
    1. Input file
    2. Country file
    3. Location File
    I want to use my input file and compare the given Country file and Location File & then output should show that user validation check is completed if user country and location are matched.
    If any of the Country file or Location file is not matched, then the output file should give the result as Validation Check failed for the user.
    Whenever you see a helpful reply, click on Vote As Helpful & click on Mark As Answer if a post answers your question.

    Below are the 3 files which i want to use in Script
    1. Input file contains below headers
    User Display Name
    SMTP Address
    NTUserID
    NTUserDomain
    Location
    Location Code
    Country
    Country Code
    Telephone Number
    2. Country approval list
    Country
    Country Code
    3.Location and Status list
    Location Code    Location Name    Status    Date
    note: status contains either yes or no
    I am trying to compare input file with 2nd file with Country or Country Code & 3rd file with location and status if everything matches.. i want the output like UserName and with a new column "Validation Success"
    If it doesn't match then i want a new column and mention the reason if Location code is not matching or Status is No for that Location Code or Country if it not present in the 2nd file.
    Hope i am able to convey my requirement
    Whenever you see a helpful reply, click on Vote As Helpful & click on Mark As Answer if a post answers your question.

  • Need to disable availability check while changing 'Reason For Order' Field in Retail Tab

    While change of STO (Me22n) I want the availability check to be disabled when a change to 'Reason for Oder' is made in the Retail Tab in the item detail.
    Let me know if there is any BADI/ User exit or enhancement available where i can do this customization.

    Hi Reddy,
    Try Transaction Variant, you can customize the screen using this tool.
    Basically, you customize the screen (hide, make it required, visible etc) then
    save it as screen variant and define a new transaction code to it.
    So for your user, just give them this new transaction code (instead of SAP standard).
    Detail about transaction variant can be checked on :
    http://help.sap.com/saphelp_crm50/helpdata/en/7d/f63a0a015111d396480000e82de14a/frameset.htm
    Hope this helps,
    Gun.

  • We need a script that will select clipping path for multiple images in indesign

    this is what we have, but it's not working:
    app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll; 
    app.doScript(resetAllClippingPathsToActiveDoc, ScriptLanguage.JAVASCRIPT, [], UndoModes.ENTIRE_SCRIPT, "Reset all Clipping Paths of the Active Document"); 
    function resetAllClippingPathsToActiveDoc(){ 
        var d=app.activeDocument; 
        var allGraphicsInDoc = d.allGraphics; 
        for(var n=0;n<allGraphicsInDoc.length;n++){ 
            if(allGraphicsInDoc[n].hasOwnProperty("clippingPath")){allGraphicsInDoc[n].clippingPath.c lippingType = ClippingPathType.PHOTOSHOP_PATH};
                allGraphicsInDoc[n].clippingPath.appliedPathName = "Path 1"; 

    this is what we have, but it's not working:
    app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll; 
    app.doScript(resetAllClippingPathsToActiveDoc, ScriptLanguage.JAVASCRIPT, [], UndoModes.ENTIRE_SCRIPT, "Reset all Clipping Paths of the Active Document"); 
    function resetAllClippingPathsToActiveDoc(){ 
        var d=app.activeDocument; 
        var allGraphicsInDoc = d.allGraphics; 
        for(var n=0;n<allGraphicsInDoc.length;n++){ 
            if(allGraphicsInDoc[n].hasOwnProperty("clippingPath")){allGraphicsInDoc[n].clippingPath.c lippingType = ClippingPathType.PHOTOSHOP_PATH};
                allGraphicsInDoc[n].clippingPath.appliedPathName = "Path 1"; 

  • Need a bat script to check Server status remotly.

    Hi,
    I need bat script to check server status remotly (Ping) for multiple servers. It should generate a txt file for result.
    Thanks.

    Hi Ravi,
    To ping multiple computers and generate report cia cmd, please refer to the script below, the "fnm" is computer name list and the "lnm" is the result, and you can save the script below as .bat file:
    @echo off
    set fnm=d:\test1\computers.txt
    set lnm=d:\test1\ping.txt
    if exist %fnm% goto Label1
    echo.
    echo Cannot find %fnm%
    echo.
    Pause
    goto :eof
    :Label1
    echo PingTest STARTED on %date% at %time% > %lnm%
    echo ================================================= >> %lnm%
    echo.
    for /f %%i in (%fnm%) do call :Sub %%i
    echo.
    echo ================================================= >> %lnm%
    echo PingTest ENDED on %date% at %time% >> %lnm%
    echo ... now exiting
    goto :eof
    :Sub
    echo Testing %1
    set state=alive
    ping -n 1 %1
    if errorlevel 1 set state=dead
    echo %1 is %state% >> %lnm%
    Refer to:
    Explain the Batch script to ping multiple computers
    If there is anything else regarding this issue, please feel free to post back.
    Best Regards,
    Anna Wang
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Support, contact [email protected]

  • Query used by SQL Server Management Pack for monitoring database backups

    I use SCOM 2012 R2 and the SQL Server Management Pack to monitor SQL Server database backups. I believe I am getting false positives. SCOM reports database are not backuped, while in fact they are. So I need to troubleshoot this. I suspect SCOM is querying
    the backup history in the msdb database. I want to know which query SCOM uses.
    I have tried looking in the monitor's definition but I suspect the query is embedded in the management pack files which are binary. I have also tried running a trace using the SQL Server Profiler on my test environment and overriding the interval to 60 seconds,
    but I don't see a relevant query being executed. I also don't see the alert reappear so I suspect SCOM does not honor the interval in a way I would expect.
    What query, or other method, does SCOM use to check database backups?
    Thanks in advance.

    Thank you both Ivan and Michael,
    I only saw your messages by email and didn't see your screen shot before I extracted the query myself. In my own queries I calculate the backup age in hours instead of days because of daily full backups. Perhaps It will be a good idea to create my own monitors
    from scratch like I used to do with Nagios.
    I will study the vbscripts and might create my own version which allows the query to be entered as an parameter and move all code to a .Net class which can be called from vbscript as an COM object. This way I hope to reduce the vbscript code to an minimum
    while keeping the flexibility of the SCOM Operations Console and the robustness of .Net. I suspect I want to make more non standard monitors in the future.
    Regards,
    Arjen

  • Restoring the database backup daily after performing some changes on d'base

    Hi all,
    Im a JUNIOR DBA... please help me..
    I have an Oracle 10g database and i have taken a cold backup for the same.(Say i have 10 users)
    MONDAY - Now, suppose out of the existing 10 users, i updated 6 tables in each user, so the total updated tables are 60 tables, these tables are only for TESTING purpose.
    TUESDAY - Now, suppose out of the existing 10 users, i updated 4 tables in each user, so the total updated tables are 40 tables, these tables are only for TESTING purpose.
    Now the question is -
    Daily i need to restore the original database backup atleast once, where in i dont want the updated tables of say MONDAY..
    Please, let me know how to proceed
    Regards,
    - Sri

    Start with the backup and recovery guide. It will tell you how to work this scenario. Basically, you will restore Sunday backup and apply archived redo logs until you reach the point in time immediately before the changes you do not want.

  • Script to check if internet is connected.

    I am new at scripting and have a problem.
    I need a script to check if my headless server, after starting up in the morning, has an Internet connection or not, and once it has established that it is connected to the Internet it needs to send me a mail that it has a connection.
    Now the mail sending part of the script I can do.
    However the checking if it has an Internet connection or not is harder and here I get stuck.
    I have the following script to check if I have a connection (found it on macinstruct.com).
    set intnt to do shell script "ping -c 1 google.com; echo -n"
    set paras to number of paragraphs in intnt
    if paras < 5 then
    Now I would like the script to recheck if it has or has no connection till it has one, and then execute sending the mail. This is where I get stuck.
    Anybody have such script or can tell me how to do this?
    Thanks.

    I am not sure that your method of checking for internet connection is ideal (and I am sure you will get some hints from others). However, what you're looking for is the repeat while ... end repeat loop.
    Note that in the example below, I have initialised your variables to an empty string and 1 respectively. You could also just repeat the lines inside the repeat loop.
    set intnt to ""
    set paras to 1
    repeat while paras < 5
    set intnt to do shell script "ping -c 1 google.com; echo -n"
    set paras to number of paragraphs in intnt
    end repeat

  • Urgent: How to have a page CONTINUE to check Database Record?

    Hello,
    How to have a page CONTINUE to check Database Record? For example, there's a page which itself will periodically check the database, if there's any new data the page will Popup a new page with those data. My question is how can the page keep checking the database?
    One of the solution(not good) is that there's a hidden frame with a hidden Servlet, it will refresh every x secs and connect database for every refresh, it seems not a good solution. Please suggest some idea. Another way is using applet.
    Someone suggest me to use JMS, I know nothing about it, so is it possible and how,thanks very much
    Thank you.
    Ken

    I don't think JMS is suitable for your solution but I know very little anyway.

  • Urgent: How to have a page CONTINUE to check Database

    Hello,
    How to have a page CONTINUE to check Database Record? For example, there's a page which itself will periodically check the database, if there's any new data the page will Popup a new page with those data. My question is how can the page keep checking the database?
    One of the solution(not good) is that there's a hidden frame with a hidden Servlet, it will refresh every x secs and connect database for every refresh, it seems not a good solution. Please suggest some idea.
    Thank you.

    You can check the database in a thread as much as you want but your problem will be sending the data to your client when it changes. Normally you can't send anything to the client until it sends a request; that's why the HTML meta-tag for refreshing works. The other way to have the client make repeated requests that was suggested was an applet. This could indeed work, except that you mentioned "mobile agent" as a requirement. Not quite sure what that is, but it's probably not a platform that supports applets. That would be a problem.
    On the other hand, if your platform is one that can receive unscheduled messages (in pager style), you could try that approach.

Maybe you are looking for