@echo off setlocal enabledelayedexpansion REM ****************************************************************************************************** REM * File: identify-oldest-images.bat REM * Desc: Determine oldest images on disk and/or on tape, and... REM * ...optionally report/select only those images which do also have a copy on tape... REM * ...and thus potentially select only those copies of images residing upon disk... REM * ...and write a ".sel" file which contains a list of the selected images and copy number. REM * REM * Vers Date Who Description REM * ---- ---- --- ----------- REM * v0.01 23-JAN-2016 sdo Initial version. REM * v0.02 24-JAN-2016 sdo Improved copy number loop. Added more comments. REM * v0.03 24-JAN-2016 sdo Check version of Windows and check version of NetBackup. REM * v0.04 3-FEB-2016 sdo Use NetBackup's own LC file to determine NetBackup date format. REM * v0.05 4-FEB-2016 sdo Handle short m/d/yyyy in bpimagelist, and AM PM (seen in US locale). REM ****************************************************************************************************** set z_script_version=v0.05 REM ****************************************************************************************************** REM * !!! WARNING and DISCLAIMER !!! REM * !!! WARNING and DISCLAIMER !!! REM * !!! WARNING and DISCLAIMER !!! REM * REM * Before using this script, be aware of the following points: REM * - Use of this script is entirely at the end user's own risk. REM * - Carefully read the entire header section of this script. Read all of the notes and make sure REM * that you have an understanding of the purpose of this script before using it. REM * - Neither the author of this script, nor Veritas, will accept any responsbility for issues or REM * problems or data loss caused by use, and/or mis-use, of this script, in either its original REM * form or in a modified form. REM * - This script is not endorsed by Veritas. REM * - This script is not supported by Veritas. REM * - This script has not been tested by Veritas. REM * - This script may not be suitable for use in any given NetBackup environment. REM * - This script is furnished on an example basis only. REM * - Whilst every effort has been made (by the author of this script) to produce something that is REM * both useful and viable, be aware that bugs and errors may remain which may cause data loss. REM ****************************************************************************************************** REM * Sharing REM * ------- REM * This script is free to share and modify, as long as this entire header section is kept with REM * the script, and maintained and updated appropriately as any changes are made. REM ****************************************************************************************************** REM * Notes REM * ----- REM * 1) This script was developed and tested using: REM * Windows 2008 R2 SP1 with NetBackup Admin Console v7.5.0.6, and Appliance v2.5.3 with tape REM * Windows 2008 R2 SP1 with NetBackup Master Server v7.7.1 with tape REM * Windows 2008 R2 SP1 with Netbackup Master Server v7.7.2 (in US locale) no tape, basic disk only REM * Windows 2012 (not R2) with NetBackup Admin Console v7.6.1.2, and Appliance v2.6.1.2 no tape REM * Windows 2012 R2 with NetBackup Master Server v7.7 no tape REM * Windows 2012 R2 with NetBackup Master Server v7.7.1 no tape REM * ...but should work with any Windows version since 2003 and any v7.* of NetBackup Server. REM * 2) This script is a form of "What if?" analysis script. This script should be safe to run on any REM * system, for several reasons: REM * i) this script will not actually make any changes. What this script does... REM * is to identify specific copies of backup images, and write the list of images to REM * a separate file. REM * ii) The details in the file will be REM'd out, so even an accidental run of the file REM * created by this script will not do anything either. REM * 3) This script tries to detect the date format, and also check that the date enterred by the REM * user is a valid date, and also checks that the entered date is less than today's date. REM * 4) This script does not check for, nor handle, SLP incomplete backup images. REM * 5) The v7.6.0.3 commands manual shows an example date format "mm/dd/yy" but says actual usage REM * is based upon NetBackup's locale setting. Luckily, we can make several different dummy REM * calls to bpexpdate, because bpexpdate will return a status 227 if a backup image does REM * does not exist, but will return status 20 if one or more of the input parameters is REM * incorrect. We know that our parameters are correct, except for the date, so... any REM * status 20 must indicate a bad date format. Thus, multiple dummy calls to bpexpdate can REM * be used to validate its own parameter formats, and depending upon which call generates REM * a status 227, we can thus determine the correct date format for bpexpdate. REM * 6) This script could result in making many calls to bpimagelist and bpverify and so could take REM * some time to run on medium to large NetBackup systems. REM * 7) This script was written because it can be even more time consuming to manually check many REM * images, and check that any given copy number applies to the desired storage unit type. REM * 8) This script will probably fail if you have 'spaces' or any strange characters in any of your REM * client names, or image names, or storage unit details, or disk pool details, or disk volume REM * details, or tape media IDs. Basically, if your NetBackup environment is in a bit of a mess REM * then you probably wouldn't want to bother attempting to run this script. REM ****************************************************************************************************** REM * Using This Script REM * ----------------- REM * 1) This script does NOT modify the host system, or NetBackup, in anyway. REM * 2) What this script will do is to write several files in the folder that it runs in. These files REM * won't be very large, but it does depend upon the size of the NetBackup catalog/environment. REM * 3) The total size of all of the files created by this script should be less than: REM * a few KB for a test environment REM * a few MB for a small NetBackup environment REM * a few ten's of MB for a medium sized NetBackup environment REM * about a hundred MB for a large NetBackup environment REM * 4) The largest file will be the ".ima" file, from "bpimagelist -idonly". REM * 5) This script does not expect, nor use, any parameters from the command line. REM * 6) This script will prompt the user with three questions, before then collecting an image list REM * and will then begin three stages of filtering that image list. REM * 7) The three prompts are for: REM * i) Whether to only consider images on disk which also have a copy on tape. REM * ii) The cutoff date, i.e. to only consider images before a specific date. REM * iii) Whether to only consider and select images on specific storage unit types. REM * 8) Run only one instance of this script at a time. It is not a multi-user script. REM ****************************************************************************************************** REM * Requirements REM * ------------ REM * 1) This script will only run on a Windows based NetBackup Master Server, or NetBackup Media Server, REM * or on an installation of the Windows based NetBackup Administration Console. REM * N.B: The "Windows NetBackup Administration Console" install is no longer available from v7.7 REM * onwards, therefore from NetBackup v7.7 onwards this script will only run on a Master or Media. REM ****************************************************************************************************** REM * List Of Files Created By This Script REM * ------------------------------------ REM * Most of the files will be created with a secondary ".txt" extension. REM *