Daily backup: how to detect non used libraries.

Hi,
We use a CL program with a list of SAVLIB commands to save all production librarires every day. The problem is that this CL has been mantained for several years and probably most of the saved libraries are not used anymore. I'm only responsible of the SAP backup lines.
How can I detect what libraries are not used now ? I've tried to look at the file attributes in this libraries but the backup itself mantains this fields.
Of course, I know that our functional people must know what is in use and what is obsolete, but in some cases the people that mantains applications has changed...
Any idea will be appreciated !!
Regards,
Joan B. Altadill
CELSA SAP Admin

I use this method in iSeries Navigator, Run an SQL script:
<begin copy>
/*---   Display the objects in the library to an outfile.  Change the value of {sourcelib} to the desired library.   ---*/
CL:     DSPOBJD OBJ(sourcelib/*ALL) OBJTYPE(*FILE) DETAIL(*SERVICE) OUTPUT(*OUTFILE) OUTFILE(QTEMP/DSPOBJDTMP)  ;
/*---   List the objects in ascending order by LastUsedDate   ---*/
SELECT      ( Char(Date(Now())) CONCAT '  '  CONCAT  Char( Time(Now())) ) DataPulled,
     (CASE      WHEN ODCDAT = ' '
          THEN     ' '
          ELSE     (CASE      WHEN ODCCEN in ( '0' , ' ' )
                    THEN       '19'
                         CONCAT SUBSTR(ODCDAT, 5, 2 )
                         CONCAT '-'
                         CONCAT SUBSTR( ODCDAT, 1, 2 )
                         CONCAT '-'
                         CONCAT SUBSTR( ODCDAT, 3, 2 )
                    ELSE     '20'
                         CONCAT SUBSTR(ODCDAT, 5,2 ) 
                         CONCAT '-'
                         CONCAT SUBSTR( ODCDAT, 1, 2 )
                         CONCAT '-'
                         CONCAT SUBSTR( ODCDAT, 3, 2 )
               END )
     END) CreationDate,
     (CASE      WHEN ODUDAT = ' '
          THEN     ' '
          ELSE     (CASE      WHEN ODUCEN in ( '0' , ' ' )
                    THEN       '19'
                         CONCAT SUBSTR(ODUDAT, 5, 2 )
                         CONCAT '-'
                         CONCAT SUBSTR( ODUDAT, 1, 2 )
                         CONCAT '-'
                         CONCAT SUBSTR( ODUDAT, 3, 2 )
                    ELSE     '20'
                         CONCAT SUBSTR(ODUDAT, 5,2 ) 
                         CONCAT '-'
                         CONCAT SUBSTR( ODUDAT, 1, 2 )
                         CONCAT '-'
                         CONCAT SUBSTR( ODUDAT, 3, 2 )
               END )
     END) LastUsedDate,
     (CASE      WHEN ODSDAT = ' '
          THEN     ' '
          ELSE     (CASE      WHEN ODSCEN in ( '0' , ' ' )
                    THEN       '19'
                         CONCAT SUBSTR(ODSDAT, 5, 2 )
                         CONCAT '-'
                         CONCAT SUBSTR( ODSDAT, 1, 2 )
                         CONCAT '-'
                         CONCAT SUBSTR( ODSDAT, 3, 2 )
                    ELSE     '20'
                         CONCAT SUBSTR(ODSDAT, 5,2 ) 
                         CONCAT '-'
                         CONCAT SUBSTR( ODSDAT, 1, 2 )
                         CONCAT '-'
                         CONCAT SUBSTR( ODSDAT, 3, 2 )
               END )
     END) SavedDate,
(CASE      WHEN ODRDAT = ' '
          THEN     ' '
          ELSE     (CASE      WHEN ODRCEN in ( '0' , ' ' )
                    THEN       '19'
                         CONCAT SUBSTR(ODRDAT, 5, 2 )
                         CONCAT '-'
                         CONCAT SUBSTR( ODRDAT, 1, 2 )
                         CONCAT '-'
                         CONCAT SUBSTR( ODRDAT, 3, 2 )
                    ELSE     '20'
                         CONCAT SUBSTR(ODRDAT, 5,2 ) 
                         CONCAT '-'
                         CONCAT SUBSTR( ODRDAT, 1, 2 )
                         CONCAT '-'
                         CONCAT SUBSTR( ODRDAT, 3, 2 )
               END )
     END) RestoreDate,
     ODCRTU CreatedBy,
     ODLBNM LibraryName,
     ODOBNM ObjectName,
     ODOBTP ObjectType,
     ODOBAT ObjectAttribute,
     ODSRCL SourceLibrary,
     ODSRCF SourceFile,
     ODSRCM SourceMember,
     (Case      When ODOBSZ = 9999999999 Then (ODSIZU * ODBPUN)
           Else ODOBSZ
     End) ObjectSize,
     ODOBTX ObjectText
FROM QTEMP.DSPOBJDTMP
Order BY LastUsedDate  ;
<end copy>
Copy/paste the code into the session, change the value of , and then Ctl+R to run all of the statements.
You can then view the results and determine if the objects haven't been used recently.
Hope this helps!
Robert
P.S.  This forum doesn't show neatly formatted code as I have it in my script, but it does work.
Message was edited by: Robert Clay
added code tags

Similar Messages

  • How To Detect Color using my application

    Hi Friends,
    Iam sachin, working as a iphone mobile application developer.K coming to my question is it possible to
    detect colors using our application if yes Kindly guide me how to proceed .
    Thanks in advance ,

    you need to ask this in the developers forum - this is a formum mostly for end users not developers

  • How to detect Browser using JSP ?

    Hi friends,
    I wanna to put some code to detect browser and
    Other than IE6+ i have to block other browser to display login.
    How do i check that ? Using JSP.
    e.g.
    If i open IE6+ login page should be displayed. Else on other browsers
    it will check brower and deny to display login page.
    How Do i check it ? please Help me.

    this code works for me in IE,Safari and firefox but i could not check in netscape as i dont have.
    String userAgent = request.getHeader("User-Agent");
          System.out.println("UserAgent:"+userAgent);
          userAgent=userAgent.toLowerCase(); //convert to lowercase and then check
          if(userAgent.indexOf("netscape6") != -1)
         System.out.println("Netscape");
          else if(userAgent.indexOf("msie") != -1)
              System.out.println("IE");
         else if(userAgent.indexOf("firefox") != -1)
         System.out.println("Firefox");
         else if(userAgent.indexOf("safari") != -1)
         System.out.println("Safari");
         else
              System.out.println("Else");
        

  • Response XML - How to remove non-used namespaces ?

    Hey guys, I have a proxy service with the following transformation:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0"
    xmlns:inf="http://dfs.us.dell.com/Infolease"
         xmlns:xsl="http://www.w3.org/1999/XSL/Transform">               
         <xsl:template match="/">          
              <xsl:if test="Envelope/Body/Response/Quotes">
                   <xsl:variable name="oNodo" select="Envelope/Body/Response/Quotes"/>          
                   <inf:GetBuyoutQuoteDetailsResponse xmlns:inf="http://dfs.us.dell.com/Infolease">
                        <inf:QtKey><xsl:value-of select="$oNodo/@pk"/></inf:QtKey>
                        <inf:QtAmtQuotedx><xsl:value-of select="$oNodo/QtAmtQuoted/text()"/></inf:QtAmtQuotedx>                    
              <inf:QtBuyoutDate><xsl:value-of select="$oNodo/QtBuyoutDate/text()"/></inf:QtBuyoutDate>
              <inf:QtExpirationDate><xsl:value-of select="$oNodo/QtExpirationDate/text()"/></inf:QtExpirationDate>
              <inf:QtQuotedDate><xsl:value-of select="$oNodo/QtQuotedDate/text()"/></inf:QtQuotedDate>
              <inf:QtRcvbBalance><xsl:value-of select="$oNodo/QtRcvbBalance/text()"/></inf:QtRcvbBalance>
              <xsl:element name="inf:QtBuyoutType">
                   <xsl:attribute name="pk"><xsl:value-of select="$oNodo/QtBuyoutType/@pk"/></xsl:attribute>
                   <xsl:element name="inf:BuyDefTypeDesc"><xsl:value-of select="$oNodo/QtBuyoutType/BuyDefTypeDesc"/></xsl:element>
              </xsl:element>                                                       
                   </inf:GetBuyoutQuoteDetailsResponse>
              </xsl:if>               
         </xsl:template>     
    </xsl:stylesheet>
    This is the response of the service after the proxy finishs:
    <?xml version="1.0" encoding="UTF-8"?>
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Header/>
    <soapenv:Body>
    <inf:GetBuyoutQuoteResponse xmlns:inf="http://dfs.us.dell.com/Infolease">
    <inf:QtKey xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">200-1122247-018*34</inf:QtKey>
    <inf:QtAmtQuotedx xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">8195.82</inf:QtAmtQuotedx>
    <inf:QtBuyoutDate xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">2011-10-04</inf:QtBuyoutDate>
    <inf:QtExpirationDate xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">2012-12-29</inf:QtExpirationDate>
    <inf:QtQuotedDate xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">2011-10-04</inf:QtQuotedDate>
    <inf:QtRcvbBalance xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">7021.83</inf:QtRcvbBalance>
    <inf:QtBuyoutType pk="BUYOUT*34"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <inf:BuyDefTypeDesc>EARLY PURCHASE-10%-TRANSACTION</inf:BuyDefTypeDesc>
    </inf:QtBuyoutType>
    </inf:GetBuyoutQuoteResponse>
    </soapenv:Body>
    </soapenv:Envelope>
    How do I remove these XSD and XSI namespaces? I haven't referenced them..
    Thanks in advance,
    Davinod

    Hi,
    Please remove the 3 non-exists DC from environment using the metadata clean-up process using script from below article. then manually delete the records from DNS management console as given below.
    https://gallery.technet.microsoft.com/scriptcenter/d31f091f-2642-4ede-9f97-0e1cc4d577f3
    Manual steps to clear the records.
    Dnsmgmt.msc [Dns Management]
    A.Expand the forward lookup zones\_msdcs folder
    i. Make sure only the actual domain controllers are listed, delete wrong Alias recordsremove wrong name server records
    ii. Select the container [forward lookup zones\_msdcs.domain.com\dc\_sites_\sitename\_tcp] > delete incorrect _ldap and _kerberos records are listed.
    iii. Select the container [forward lookup zones\_msdcs.domain.com\dc\_tcp] and delete incorrect _ldap and _kerberos records
    iv. Expand the [forward lookup zones\_msdcs.domain.com\domains\guid\_tcp] and delete incorrect _ldap entries
    v. Select [forward lookup zones\_msdcs.domain.com\gc] – delete incorrect HostA records
    vi. Expand the [forward lookup zones\_msdcs.domain.com\gc\_sites\sitename\_tcp] – delete incorrect _ldap entries
    vii.Select the [forward lookup zones\_msdcs.domain.com\gc\_tcp] – delete incorrect _ldap entries
    viii. Select the [forward lookup zones\_msdcs.domain.com\pdc\_tcp] – delete incorrect _ldap entries
    B.Expand the forward lookup zones\domain.com folder
    i.Delete Host(A) records of dc’s which are non-existant.
    ii.Correct the NameServer (NS) records
    iii. Follow steps similar to ’ A ii ‘ >> ‘ A viii’
    · Dssite.msc [Sites and Services]
    A.Expand the [Sites\Sitename\Servers] – delete incorrect server’s
    B.Delete incorrect subnet configurations [Sites\Subnets]
    C.Delete incorrect site links [Sites\IP]
    · Make sure the domain controllers are pointing to the correct dns servers in tcp\ip settings.
    · Force replication – ‘repadmin /syncall’

  • How to detect usb6009 using c++

    how do i detect the name of the attached device in c++?
    also how do i detect available channels in c++?

    char buffer[100];
    char *p = buffer;
    wxString active;
    DAQmxGetSysDevNames(p,32);
    active << p;
    i already found how to get device name. 
    i just need to know how to find the list of channels.

  • How to detect Non-English characters

    I have a report containing Korean language and English in a single column.
    My requirement is to detect the Korean language and pass it to the place holder column and detect English language and pass it to other place holder column.
    Please help me guys.

    is both English and Korean letters are in the same column without any space gab or any separator, ? Pl re check

  • How to detect sound using JMF

    Hi,
    I want to detect a beep sound that is played on the machine by another application. Basically, connect to the sound card and see if beep was played. This sound would effectively play on the machine speakers. if speakers are present.
    I want to eventually grab a couple of sounds but first start with beep. So, over a duration of 2 minutes, I would alternate between 'beep' and 'bang'. And whenever these sounds are played, I want to be able to detect them.
    I would appreciate if there is sample code that I can start with.
    I am new to java audio/media and most data that I found was recording sound from microphone.
    Thanks.

    I tried getting the device list on my system but the following code is not returning any devices (deviicelist is empty) ? When I look at my Device Manager on Windows7 machine, I see there is 'High Definition audio device' . Does anyone have a clue why/when would this happen ?
    I have jmf installed and it is in the classpath. I also have jmf.jar, sound.jar added to my project.
    CaptureDCaptureDeviceInfo di = null;
    Vector deviceList = CaptureDeviceManager.getDeviceList(
                        null);
              if (deviceList.isEmpty())
                   System.out.println("No Devices found");
              if ( deviceList.size() > 0 )
              di = (CaptureDeviceInfo)deviceList.firstElement();
              System.out.println("di::" + di.getName());

  • HT1766 How can I backup the iPad to the non-C drive of the computer that runs the itune?   I have already setup the library at a NAS and seems only media file are stored int he library.  iPad backup still need to take use my C: drive that is running out o

    How can I backup the iPad to the non-C drive of the computer that runs the itune?   I have already setup the library at a NAS and seems only media file are stored int he library.  iPad backup still need to take use my C: drive that is running out of space

    Windows - Change iPad default backup location
    http://apple-ipad-tablet-help.blogspot.com/2010/07/change-ipad-default-backup-lo cation.html
    Windows - Changing IPhone and iPad backup location
    http://goodstuff2share.wordpress.com/2011/05/22/changing-iphone-and-ipad-backup- location/
     Cheers, Tom

  • How do TM daily backups transition to weekly backups ?

    How do TM daily backups transition to weekly backups is something I'm trying to figure out.
    As of Saturday Dec 1 at 0000 hrs I had daily backups for
    Oct 28
    I had none for Oct 29, 30 and 31
    Nov 1, 2, 3, 4, 5 and 6
    I had none for Nov 7 thru 14
    Nov 15 thru 30
    I've been tracking this info on an hourly basis via a crontab entry setup using CronniX.
    When TM did its hourly backup on Sat Dec 1 at around 0030 hours the Nov 1 daily backup was removed with TM reporting it had expired.
    When TM did its hourly backup on Sun Dec 2 at 0032 hours the Nov 2 daily backup was removed with TM reporting it had expired.
    Note that the Oct 28 backup is not being deleted/expired.
    At this rate from now on I'm wondering just how many of my November daily backups will get removed by TM is the wee hours of the morning at around 0030 hours!
    What I'm really curious to see is how TM designates a weekly backup.
    Has anyone seen a TM weekly backup show up yet and if so how is it labelled on the TM backup Volume and in the TM browser's date/time tick marks located vertical on the right had side ?
    Thanks....

    My thoughts on this at this time is that the Oct 28 daily backup contains all the necessary backup data that was contained in the Nov 1 and Nov 2 backups so therefore TM can expire/delete them with impunity. It will do this with the Nov 3, 4, 5, 6, etc until it finds some backed up daily data that does not exist in the Oct 28 backup. We will see as time moved forward.

  • I have been storing my Aperture and IMovie Libraries on an external hard drive that recently died.  Fortunately I've been using Time Machine to back up to a 2nd external drive.  How do I restore my libraries to a new external hard drive?

    I have been storing my Aperture and IMovie Libraries on an external hard drive that recently died.  Fortunately I've been using Time Machine to back up to a 2nd external drive.  How do I restore my libraries to a new external hard drive?

    This is a tricky one.
    Open up Time Machine and go back to a date using the timeline on the right side of the window when you know the drive was working and was backing up as part of Time Machine backups.
    Click on the name of your Mac under the Devices heading on the left side of the window in Time Machine, and if things are working correctly you will see Macintosh HD (or whatever you have named it) and the name of the external hard drive that was backing up in the past.
    Right-Click on the name of the external hard drive and then click on "Restore (name of drive) to....."  You may be asked for your adminstrator password at this point.
    It might be easier to restore the drive contents to your desktop if you have room on your Mac, and then copy things over to the new external drive where you want to store the Aperture and iMovie Libraries.
    Once the libraries have been moved over the new external hard drive, you will likely need to "point" Aperture and iMovie to the location of the libraries on the new external hard drive.

  • How to Delete Non-System State Backups in Windows 2008R2

    Hello,
    I am running a Windows 2008R2 server which uses Windows Server Backup to do the backups. We are using the backup-tool to create non-system state backups of the data-directories on this machine. The backup is done on a dedicated disk connected through iscsi
    (to a Synology box). This backup disk has become too small and we have now replaced the Synology box with a bigger one. Here i created a new LUN again for the backup purposes.
    Now for my question; The wbadmin.exe tool supplied with W2008R2 does not offer a way to delete the old backups. I know that in Win2012 (which we we also have running) I could add the new iscsi location and then (when enough backups are available on the new
    target) use wbadmin.exe delete backup  to delete the old non-system state backups; e.g.
     wbadmin delete backup -version:08/07/2013-21:00
    This (very undocumented) feature of Windows 2012 and higher works quite nice and is exactly what i am searching for on the W2008R2 machine; a way to delete the old backups (and under the hood delete the corresponding snapshots)
    I've done quite a bit of research and it should be possible to do something similar in 2008 but then manually, The howto is described in the following link: http://blogs.technet.com/b/filecab/archive/2009/06/22/backup-version-and-space-management-in-windows-server-backup.aspx .
    Basically it describes that you should use DiskShadow.exe to remove e.g. the oldest snapshot with a  command like :
    Delete shadows OLDEST \\?\Volume{7fc1871b-2e1f-11dd-a339-001e4fb7af35}
    Windows Server backup (wbadmin) should then on the next run 'see' this deletion and update its list of available backups:
    "You can perform the same steps manually to delete backups on demand. However, the backup catalog update cannot be done manually and it will happen instead during
    the next backup."
    I've done this on our box and it indeed removes the shadows from the list. However, in the Windows Backup 'dashboard' it still lists the backups as available. Also after a new backup has finished (according the the article this is when it should 'update'
    its backup catalog). When I try to restore a backup from a date that i just removed it gives a nice message that this is impossible because the snapshot is not available (duh :)) ;
    Unable to browse Local disk. The shadow copy of the backup stored on the backup destination cannot be found.
    So it seems that the aforementioned method works; it removes the snapshot and frees diskspace, but it doesn't update the Windows Backup catalog. As a result the management tool (GUI) still lists the backups which are no longer available! How can i change
    this? Is there any way to do this? I found one article which mentions that the Dashboard bases its screen on the Windows Logs and not on the actual VSS snapshots available:
    http://forum.wegotserved.com/index.php/topic/23757-start-afresh-with-server-backup/ (WHS) In my situation however this seems unlikely because i don't have any logs that date back as far as my backups go.
    In my opinion this is a real bug and it leaves us with a in-consequent backup schema. Does anyone have similar situations or even a solution to my problem?
    Kind Regard, Martin

    Hi Mandy,
    Yes! I think i got my answer and I now get how windows backup works in Windows 2008 :-) It turns out that I dismissed some suggestions a bit too soon. The answer lies in the command mentioned earlier : 
    Wbadmin delete catalog
    This command does delete all the backups from a perspective of the Windows Backup UI, but leaves the VSS snapshots intact. This means that the backups are still available, but you just can't restore them with the User Interface. In order to 'update' the
    UI with the current available snapshots (which you can list with diskshadows list shadows all), you have to re-add the existing media on which the backups took place using the Wizard of the UI. It will then inform you that existing backups are available and
    if you want to keep these for restore purposes. If you click 'yes', and THEN perform a backup ... All the current available backups will be shown in the User Interface :-) 
    So for my steps taken to change from one iscsi (iscsi1) to another (iscsi2):
    - Add the 2nd iscsi target with the Windows Backup UI
    using Backup schedule , Modify backup -> [desired options] => Add more backup destinations -> iscsi2
    - Remove the 1st iscsi target with the Windows Backup UI
    using Backup schedule , Modify backup -> [desired options] => Remove current backup destinations -> iscsi1
    - Run some backups on the new destination. Old restore points are now still available. When enough restore points are available on the new volume iscsi2 start deleting old data from iscsi1 as follows:
    - Run diskshadow
    diskshadow
    - list all the current snapshots
    list shadows all
    - remove all the snapshots of iscsi1  (repeat until all shadows are gone of iscsi1)
    delete shadows oldest \\?\volume{yourvolumeid}\
    - delete the windows backup catalog
    wbadmin delete catalog
    - Restart the windows backup UI and re-add your schedule on the new volume iscsi2. It will now ask if you want the keep the existing data for restore purposes; click yes. 
    - After the next backup only the backups of volume iscsi2 will be listed and everything is fine ! 
    I Hope my post will help others with similar questions. It was quite a search before I understood the way it works. Basically as long as your VSS snapshots are still available and listed by diskshadow you still have the backups and you will be able to get
    this in sync with the steps above (delete schedule and re-add originating targets containing the snapshots). After the next backup the UI will update itself. 
    (In my case someway along the way I lost my originating snapshots, but because I already had my new backup set it didn't bother me; It kept me from having to delete all 510 old backups :) with diskshadow)
    Regard, Martin

  • Daily backup for a certain folder on my desktop using Ipod - Possible?

    I would like to use my iPod as a memory media to perform a daily backup (at a certain given time, every day) for a folder in my computer. How do I do that?
    Do I need to have some sort of a software that will be directed to the iPod as its media? Is such a thing possible?
    Thanks a lot...
    R.

    Hmmm... I've never done something like that myself... I would imagine you would need a dedicated application for backing up.
    Maybe someone will come along who knows more. Otherwise, you might try Google.
    Cheers!
    -Bryan
    p.s. thanks for the gold star.

  • How to detect corrupt archivelog? and continue the backup.

    Hi Folks,
    In RMAN, While doing backup of archivelog, I am getting some error regarding some archivelog are corrupt.I have two question here?
    1) How to detect that particular archivelog is corrupt or not?
    2) how to continue the backup even if we have corrupt archivelog?
    Thanks
    Shailesh

    Shailesh.mishra wrote:
    Hi Folks,
    In RMAN, While doing backup of archivelog, I am getting some error regarding some archivelog are corrupt.I have two question here?
    1) How to detect that particular archivelog is corrupt or not?DBV can be used to detect corruption or archives.
    2) how to continue the backup even if we have corrupt archivelog?What kind of error you are experincing? You can use skip clause if you know which one is corrupted.
    HTH
    Aman....

  • My husband and I share a new PC.  We have different music tastes and each have an iphone.  How can we both use our one computer and one itunes program with separate music libraries and separate iphones?

    My husband and I share a new PC.  We have different music tastes and each have an iphone.  How can we both use our one computer and one itunes program with separate music libraries and separate iphones?

    Each device only syncs waht you select.
    Select only what you want for each phone.

  • How to backup more than one database using powershell

    I am Trying to backup more than one database using the following script but no luck. I want user to type on command line the database they want to backup, e.g all databases that have "test" at the front like test.inventory, test.sales so i want
    user to type test.* and it backs up all databases related to test. Here is the script
        #$date = Get-Date -Format yyyyMMddHHmmss
        #$dbname = 'test.inventory'
        $dbToBackup = "test.inventory"
        cls
        [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | Out-Null
        [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SmoExtended") | 
        Out-Null
        [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.ConnectionInfo") 
        | Out-Null
        [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SmoEnum") | Out-
        Null
        Add-Type -AssemblyName "Microsoft.SqlServer.Smo, Version=10.0.0.0, Culture=neutral,   
        PublicKeyToken=89845dcd8080cc91"
        $server = New-Object Microsoft.SqlServer.Management.Smo.Server($env:ComputerName) 
        $server.Properties["BackupDirectory"].Value = "C:\_DBbackups"
        $server.Alter()
        $backupDirectory = $server.Settings.BackupDirectory
        #display default backup directory
        "Default Backup Directory: " + $backupDirectory
        $db = $server.Databases[$dbToBackup]
        $dbName = $db.Name
        $timestamp = Get-Date -format yyyyMMddHHmmss
        $smoBackup = New-Object ("Microsoft.SqlServer.Management.Smo.Backup")
        #BackupActionType specifies the type of backup.
        #Options are Database, Files, Log
        #This belongs in Microsoft.SqlServer.SmoExtended assembly
        $smoBackup.Action = "Database"
        $smoBackup.BackupSetDescription = "Full Backup of " + $dbName
        $smoBackup.BackupSetName = $dbName + " Backup"
        $smoBackup.Database = $dbName
        $smoBackup.MediaDescription = "Disk"
        $smoBackup.Devices.AddDevice($backupDirectory + "\" + $dbName + "_" + $timestamp +   
        ".bak", "File")
        $smoBackup.SqlBackup($server)
        #let's confirm, let's list list all backup files
        $directory = Get-ChildItem $backupDirectory
        $backupFilesList = $directory | where {$_.extension -eq ".bak"}
        $backupFilesList | Format-Table Name, LastWriteTime

    Or i am using this script which backs up everything except tempdb but dont know how to modify this so that it backs up up all test related databases
    Is there a way that i use test.*
    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | out-null
    $s = new-object ("Microsoft.SqlServer.Management.Smo.Server") $instance
    $bkdir = "C:\_DBbackups" #We define the folder path as a variable 
    $dbs = $s.Databases
    foreach ($db in $dbs) 
         if($db.Name -ne "tempdb") #We don't want to backup the tempdb database 
         $dbname = $db.Name
         $dt = get-date -format yyyyMMddHHmm #We use this to create a file name based on the timestamp
         $dbBackup = new-object ("Microsoft.SqlServer.Management.Smo.Backup")
         $dbBackup.Action = "Database"
         $dbBackup.Database = $dbname
         $dbBackup.Devices.AddDevice($bkdir + "\" + $dbname + "_db_" + $dt + ".bak", "File")
         $dbBackup.SqlBackup($s)

Maybe you are looking for

  • Order with ref to quotation

    Hi All, When i create order with ref to a quotation i give create with ref and give the quotation number and click on items for choosing the quantity(OPEN QUANTITY) , here i want to know the quantity which i choose , where does this get updated ? VBA

  • Custom page size in PSE 9 photobooks?

    Does anyone know a way that allows one to create a photo book with a freely selected page size, such as 20 x 25 cm in PSE 9? The size options that present themselves when creating a book are quite limited, so I'm wondering whether there is a way to d

  • Computex girls? Which year of pictures do you have?

    Computex is coming, which years of Computex girls's photo do u keep? I find pictures of Y2010, you can see MSI Notebook promoting it's Gaming series

  • User unable to umount samba share

    Here is the lines in my /etc/fstab related to samba shares. # Some Windows/SAMBA shares //BAO-QNAP500GB/USB\040Disk\0401 /mnt/eBooks smbfs workgroup=BAO-HOME,username=xxxxxx,ip=192.168.2.4,password=xxxxxx,noauto,noatime,user,rw 0 0 I am able to mount

  • Mail - Mail Activity Counts Upwards But No New Emails Arrive

    This is really annoying me... Since Leopard, Mail keeps going to one of my email addresses and continues to count upwards saying 'Incoming Messages' above the progression bar. I have to sometimes leave it on overnight for it to resolve. During the da