{"id":678,"date":"2013-05-15T19:02:00","date_gmt":"2013-05-15T19:02:00","guid":{"rendered":"https:\/\/www.geekmungus.co.uk\/?p=678"},"modified":"2022-11-05T10:53:19","modified_gmt":"2022-11-05T10:53:19","slug":"dpm-2007-and-dpm-2010-remove-damaged-tape-from-database","status":"publish","type":"post","link":"https:\/\/geekmungus.co.uk\/?p=678","title":{"rendered":"DPM 2007 and DPM 2010 &#8211; Remove Damaged Tape from Database"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Tapes are basically sticky tape and rust, therefore they are liable to break especially your weekly rotation ones, just because they get wear and tear. When this happens and the tape is no longer able to be used, we need to remove it from DPM to stop it appearing the in the tape request reports. With DPM, there isn&#8217;t anyway to remove the tape using the GUI so you need to run a SQL script to get rid of the tape and stop it asking for something you can never put into the tape drive.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1. First get hold of the tape label name, for example: <strong>000013L4<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2. Next backup your DPMDB database, this is a must, if this script corrupts it you want to be able to restore. You can do this by:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2.1 DPMBACKUP -db (The database will be saved in the C:\\Program Files\\Microsoft DPM\\DPM\\Volumes\\ShadowCopy\\Database Backups folder.)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2.2 Microsoft SQL Management Studio &#8211; Start off a (copy) backup of the DB and store it somewhere safe.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">3. Now open the Microsoft SQL Management Studio, open a &#8220;new query&#8221;, select the DPMDB database as the target for the operation.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">4. Now paste into the window the following:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>---------- START COPY HERE -------------\n\n \n\n-- overdue tapes\n\n -- for clarity, set up the parameter as a variable\n\n declare @paramTapeLabel as nvarchar(256)\n\n set @paramTapeLabel = 'SAMPLE_TAPE_LABEL_NAME'\n\n \n\n-- keys\n\n declare @vMediaId as guid\n\n declare @vGlobalMediaId as guid\n\n \n\n-- if the delete gives trouble, add keyset after cursor\n\n declare cur_label cursor\n\n for select MediaId, GlobalMediaId\n\n from tbl_MM_Media\n\n where label = @paramTapeLabel;\n\nopen cur_label\n\n while (0 = 0)\n\n begin\n\n fetch next from cur_label into @vMediaId, @vGlobalMediaId\n\n -- test for being done\n\n if @@fetch_status &lt;> 0 break;\n\nprint 'Deleting MediaId = ' + cast(@vMediaId as varchar(36))\n\n -- do a set of deletes atomically\n\n begin transaction;\n\n delete from tbl_MM_TapeArchiveMedia\n\n   where MediaId = @vMediaId;\n\ndelete from tbl_MM_MediaMap\n\n   where MediaId = @vMediaId;\n\ndelete from tbl_MM_ArchiveMedia\n\n   where MediaId = @vMediaId;\n\ndelete from tbl_MM_Global_ArchiveMedia\n\n   where MediaId = @vGlobalMediaId;\n\ndelete from tbl_MM_Global_Media\n\n   where MediaId = @vGlobalMediaId;\n\ndelete from tbl_MM_Media\n\n   where current of cur_label;\n\ncommit transaction;\n\nend\n\n close cur_label\n\n deallocate cur_label\n\n \n\n-------------- END COPY HERE ----------------------<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">5. Alter the line <strong>@paramtapelabel<\/strong> where the N&#8217;SAMPLE_TAPE_LABEL_NAME&#8217; should be replaced with: <strong>&#8216;000013L4&#8217; <\/strong>(that&#8217;s right you leave in the single quotes, or it won&#8217;t work.)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">6. Now execute the script, assuming it worked without error, that&#8217;s it the tape has been deleted from the database.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">7. You should find that the next tape report won&#8217;t contain the faulty tape as it no longer knows about it and the job will use a new one instead.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">CITATION:<a href=\"http:\/\/www.google.com\/url?q=http%3A%2F%2Fsocial.technet.microsoft.com%2FForums%2Ffr-FR%2Fdpmtapebackuprecovery%2Fthread%2Fdede3c6c-aa37-440e-9205-25008d89059b&amp;sa=D&amp;sntz=1&amp;usg=AFQjCNEw49id-Z2DScC1rWaCtXxBh4MeBA\" target=\"_blank\" rel=\"noreferrer noopener\"> <\/a><a href=\"http:\/\/www.google.com\/url?q=http%3A%2F%2Fsocial.technet.microsoft.com%2FForums%2Ffr-FR%2Fdpmtapebackuprecovery%2Fthread%2Fdede3c6c-aa37-440e-9205-25008d89059b&amp;sa=D&amp;sntz=1&amp;usg=AFQjCNEw49id-Z2DScC1rWaCtXxBh4MeBA\" target=\"_blank\" rel=\"noreferrer noopener\">http:\/\/social.technet.microsoft.com\/Forums\/fr-FR\/dpmtapebackuprecovery\/thread\/dede3c6c-aa37-440e-9205-25008d89059b<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I&#8217;ve repeated this post on my site as its too good to lose to the Interwebs.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>UPDATE for Microsoft DPM 2010<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you are using Microsoft DPM 2010, you need to adjust the code slightly, because the name has been changed of one of the columns where it has the Label = @paramTapeLabel; you need to change this toBarcodeValue = @paramTapeLabel; instead. Now when you run this script you should see 5 or 6 results saying:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Deleting MediaId = 5DCFFDBC-29E9-4572-B1C1-BE1A9A10A237<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">(1 row(s) affected)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">(5 row(s) affected)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">(1 row(s) affected)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">(1 row(s) affected)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">(1 row(s) affected)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">(1 row(s) affected)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>-- overdue tapes\n\n -- for clarity, set up the parameter as a variable\n\n declare @paramTapeLabel as nvarchar(256)\n\n set @paramTapeLabel = '000013L4'\n\n-- keys\n\n declare @vMediaId as guid\n\n declare @vGlobalMediaId as guid\n\n-- if the delete gives trouble, add keyset after cursor\n\n declare cur_label cursor\n\n for select MediaId, GlobalMediaId\n\n from tbl_MM_Media\n\n where BarcodeValue = @paramTapeLabel;\n\nopen cur_label\n\n while (0 = 0)\n\n begin\n\n fetch next from cur_label into @vMediaId, @vGlobalMediaId\n\n -- test for being done\n\n if @@fetch_status &lt;> 0 break;\n\nprint 'Deleting MediaId = ' + cast(@vMediaId as varchar(36))\n\n -- do a set of deletes atomically\n\n begin transaction;\n\n delete from tbl_MM_TapeArchiveMedia\n\n   where MediaId = @vMediaId;\n\ndelete from tbl_MM_MediaMap\n\n   where MediaId = @vMediaId;\n\ndelete from tbl_MM_ArchiveMedia\n\n   where MediaId = @vMediaId;\n\ndelete from tbl_MM_Global_ArchiveMedia\n\n   where MediaId = @vGlobalMediaId;\n\ndelete from tbl_MM_Global_Media\n\n   where MediaId = @vGlobalMediaId;\n\ndelete from tbl_MM_Media\n\n   where current of cur_label;\n\ncommit transaction;\n\nend\n\n close cur_label\n\n deallocate cur_label<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This seemed to cure the problem for me.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Tapes are basically sticky tape and rust, therefore they are liable to break especially your weekly rotation ones, just because they get wear and tear. When this happens and the tape is no longer able to be used, we need to remove it from DPM to stop it appearing the in the tape request reports. &#8230; <a title=\"DPM 2007 and DPM 2010 &#8211; Remove Damaged Tape from Database\" class=\"read-more\" href=\"https:\/\/geekmungus.co.uk\/?p=678\" aria-label=\"Read more about DPM 2007 and DPM 2010 &#8211; Remove Damaged Tape from Database\">Read more<\/a><\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":["post-678","post","type-post","status-publish","format-standard","hentry","category-microsoft-dpm"],"_links":{"self":[{"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/678","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=678"}],"version-history":[{"count":1,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/678\/revisions"}],"predecessor-version":[{"id":1487,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/678\/revisions\/1487"}],"wp:attachment":[{"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=678"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=678"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=678"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}