|
Posted by Bryan on 03/13/07 20:49
We have a SQL 2005 server running the following backup job:
<font face="Courier New" size="2"><br><font color="blue">/* Created by
<a href="http://www.wangz.net/gsqlparser/sqlpp/sqlformat.htm">free
online sql formatter</a> */</font><br><br>
<font color = "blue">EXECUTE</font> <font color =
"maroon">master</font><font color = "silver">.</font><font color =
"maroon">dbo</font><font color = "silver">.</font><font color =
"#8000FF">xp_create_subdir</font>
<br> <font color = "red">N'\\Server\Backups
\DBServerName\\DB_Name__METABASE'</font>
<br><br>
<font color = "blue">GO</font>
<br><br>
<font color = "blue">EXECUTE</font> <font color =
"maroon">master</font><font color = "silver">.</font><font color =
"maroon">dbo</font><font color = "silver">.</font><font color =
"#8000FF">xp_create_subdir</font>
<br> <font color = "red">N'\\server\Backups
\DBServerName\\DB_Name__MSCRM'</font>
<br><br>
<font color = "blue">GO</font>
<br><br>
<font color = "blue">BACKUP</font> <font color = "blue">DATABASE</
font> <font color = "maroon">[db_name__metabase]</
font> <font color = "blue">TO</font> <font color =
"maroon">disk</font> <font color = "silver">=</font> <font
color = "red">N'\\server\Backups\DBServerName\\DB_Name__METABASE
\DB_Name__METABASE_backup_200610261158.bak'</font> <font color =
"blue">WITH</font> <font color = "maroon">differential</
font> <font color = "silver">,</font> <font color =
"maroon">noformat</font> <font color = "silver">,</
font> <font color = "maroon">noinit</font> <font color =
"silver">,</font> <font color = "maroon">name</font> <font
color = "silver">=</font> <font color =
"red">N'DB_Name__METABASE_backup_20061026115839'</font> <font
color = "silver">,</font> <font color = "maroon">skip</
font> <font color = "silver">,</font> <font color =
"maroon">rewind</font> <font color = "silver">,</font> <font
color = "maroon">nounload</font> <font color = "silver">,</
font> <font color = "maroon">stats</font> <font color =
"silver">=</font> <font color = "black">10</font>
<br><br>
<font color = "blue">GO</font>
<br><br>
<font color = "blue">DECLARE</font> <font color =
"#8000FF">@backupSetId</font> <font color = "blue">AS</
font> <font color = "black">INT</font>
<br><br>
<font color = "blue">SELECT</font> <font color =
"#8000FF">@backupSetId</font> <font color = "silver">=</
font> <font color = "maroon">position</font>
<br><font color = "blue">FROM</font> <font color =
"maroon">msdb</font><font color = "silver">.</font><font color =
"silver">.</font><font color = "maroon">backupset</font>
<br><font color = "blue">WHERE</font> <font color =
"maroon">database_name</font> <font color = "silver">=</
font> <font color = "red">N'DB_Name__METABASE'</font>
<br> <font color =
"blue">AND</font> <font color = "maroon">backup_set_id</
font> <font color = "silver">=</font> <font color =
"silver">(</font><font color = "blue">SELECT</font> <font color =
"fuchsia"><b>MAX</font></b><font color = "silver">(</font><font color
= "maroon">backup_set_id</font><font color = "silver">)</font>
<br> <font
color = "blue">FROM</font> <font color =
"maroon">msdb</font><font color = "silver">.</font><font color =
"silver">.</font><font color = "maroon">backupset</font>
<br> <font
color = "blue">WHERE</font> <font color =
"maroon">database_name</font> <font color = "silver">=</
font> <font color = "red">N'DB_Name__METABASE'</font><font color
= "silver">)</font>
<br><br>
<font color = "blue">IF</font> <font color =
"#8000FF">@backupSetId</font> <font color = "blue">IS</
font> <font color = "blue">NULL</font>
<br> <font color = "blue">BEGIN</font>
<br> <font color = "blue">RAISERROR</
font> <font color = "silver">(</font><font color =
"red">N'Verify failed. Backup information for database ''DB_Name__METABASE'' not found.'</
font><font color = "silver">,</font><font color = "black">16</
font><font color = "silver">,</font><font color = "black">1</
font><font color = "silver">)</font>
<br> <font color = "blue">END</font>
<br><br>
<font color = "blue">RESTORE</font> <font color =
"maroon">verifyonly</font> <font color = "blue">FROM</
font> <font color = "maroon">disk</font> <font color =
"silver">=</font> <font color = "red">N'\\server\Backups
\DBServerName\\DB_Name__METABASE
\DB_Name__METABASE_backup_200610261158.bak'</font> <font color =
"blue">WITH</font> <font color = "blue">FILE</font> <font
color = "silver">=</font> <font color = "#8000FF">@backupSetId</
font> <font color = "silver">,</font> <font color =
"maroon">nounload</font> <font color = "silver">,</
font> <font color = "maroon">norewind</font>
<br><br>
<font color = "blue">GO</font>
<br><br>
<font color = "blue">BACKUP</font> <font color = "blue">DATABASE</
font> <font color = "maroon">[db_name__mscrm]</font> <font
color = "blue">TO</font> <font color = "maroon">disk</
font> <font color = "silver">=</font> <font color = "red">N'\
\server\Backups\DBServerName\\DB_Name__MSCRM
\DB_Name__MSCRM_backup_200610261158.bak'</font> <font color =
"blue">WITH</font> <font color = "maroon">differential</
font> <font color = "silver">,</font> <font color =
"maroon">noformat</font> <font color = "silver">,</
font> <font color = "maroon">noinit</font> <font color =
"silver">,</font> <font color = "maroon">name</font> <font
color = "silver">=</font> <font color =
"red">N'DB_Name__MSCRM_backup_20061026115839'</font> <font color
= "silver">,</font> <font color = "maroon">skip</font> <font
color = "silver">,</font> <font color = "maroon">rewind</
font> <font color = "silver">,</font> <font color =
"maroon">nounload</font> <font color = "silver">,</
font> <font color = "maroon">stats</font> <font color =
"silver">=</font> <font color = "black">10</font>
<br><br>
<font color = "blue">GO</font>
<br><br>
<font color = "blue">DECLARE</font> <font color =
"#8000FF">@backupSetId</font> <font color = "blue">AS</
font> <font color = "black">INT</font>
<br><br>
<font color = "blue">SELECT</font> <font color =
"#8000FF">@backupSetId</font> <font color = "silver">=</
font> <font color = "maroon">position</font>
<br><font color = "blue">FROM</font> <font color =
"maroon">msdb</font><font color = "silver">.</font><font color =
"silver">.</font><font color = "maroon">backupset</font>
<br><font color = "blue">WHERE</font> <font color =
"maroon">database_name</font> <font color = "silver">=</
font> <font color = "red">N'DB_Name__MSCRM'</font>
<br> <font color =
"blue">AND</font> <font color = "maroon">backup_set_id</
font> <font color = "silver">=</font> <font color =
"silver">(</font><font color = "blue">SELECT</font> <font color =
"fuchsia"><b>MAX</font></b><font color = "silver">(</font><font color
= "maroon">backup_set_id</font><font color = "silver">)</font>
<br> <font
color = "blue">FROM</font> <font color =
"maroon">msdb</font><font color = "silver">.</font><font color =
"silver">.</font><font color = "maroon">backupset</font>
<br> <font
color = "blue">WHERE</font> <font color =
"maroon">database_name</font> <font color = "silver">=</
font> <font color = "red">N'DB_Name__MSCRM'</font><font color =
"silver">)</font>
<br><br>
<font color = "blue">IF</font> <font color =
"#8000FF">@backupSetId</font> <font color = "blue">IS</
font> <font color = "blue">NULL</font>
<br> <font color = "blue">BEGIN</font>
<br> <font color = "blue">RAISERROR</
font> <font color = "silver">(</font><font color =
"red">N'Verify failed. Backup information for database ''DB_Name__MSCRM'' not found.'</
font><font color = "silver">,</font><font color = "black">16</
font><font color = "silver">,</font><font color = "black">1</
font><font color = "silver">)</font>
<br> <font color = "blue">END</font>
<br><br>
<font color = "blue">RESTORE</font> <font color =
"maroon">verifyonly</font> <font color = "blue">FROM</
font> <font color = "maroon">disk</font> <font color =
"silver">=</font> <font color = "red">N'\\server\Backups
\DBServerName\\DB_Name__MSCRM\DB_Name__MSCRM_backup_200610261158.bak'</
font> <font color = "blue">WITH</font> <font color =
"blue">FILE</font> <font color = "silver">=</font> <font
color = "#8000FF">@backupSetId</font> <font color = "silver">,</
font> <font color = "maroon">nounload</font> <font color =
"silver">,</font> <font color = "maroon">norewind</font>
</font>
This job was set up long before i started here and the problem is that
the backup file itself has grown to be over 230 GB. It does not
appear that the backup job is pruning the file. is there a way to
view the contents of this file and then prune it so we keep no more
then two weeks worth of data.
Thanks
[Back to original message]
|