You are here: SQL 2005 Backup File « MsSQL Server « IT news, forums, messages
SQL 2005 Backup File

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>&nbsp;<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>&nbsp;&nbsp;&nbsp;<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>&nbsp;<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>&nbsp;&nbsp;&nbsp;<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>&nbsp;<font color = "blue">DATABASE</
font>&nbsp;<font color = "maroon">[db_name__metabase]</
font>&nbsp;<font color = "blue">TO</font>&nbsp;<font color =
"maroon">disk</font>&nbsp;<font color = "silver">=</font>&nbsp;<font
color = "red">N'\\server\Backups\DBServerName\\DB_Name__METABASE
\DB_Name__METABASE_backup_200610261158.bak'</font>&nbsp;<font color =
"blue">WITH</font>&nbsp;<font color = "maroon">differential</
font>&nbsp;<font color = "silver">,</font>&nbsp;<font color =
"maroon">noformat</font>&nbsp;<font color = "silver">,</
font>&nbsp;<font color = "maroon">noinit</font>&nbsp;<font color =
"silver">,</font>&nbsp;<font color = "maroon">name</font>&nbsp;<font
color = "silver">=</font>&nbsp;<font color =
"red">N'DB_Name__METABASE_backup_20061026115839'</font>&nbsp;<font
color = "silver">,</font>&nbsp;<font color = "maroon">skip</
font>&nbsp;<font color = "silver">,</font>&nbsp;<font color =
"maroon">rewind</font>&nbsp;<font color = "silver">,</font>&nbsp;<font
color = "maroon">nounload</font>&nbsp;<font color = "silver">,</
font>&nbsp;<font color = "maroon">stats</font>&nbsp;<font color =
"silver">=</font>&nbsp;<font color = "black">10</font>

<br><br>
<font color = "blue">GO</font>

<br><br>
<font color = "blue">DECLARE</font>&nbsp;&nbsp;<font color =
"#8000FF">@backupSetId</font>&nbsp;&nbsp;<font color = "blue">AS</
font>&nbsp;<font color = "black">INT</font>

<br><br>
<font color = "blue">SELECT</font>&nbsp;<font color =
"#8000FF">@backupSetId</font>&nbsp;<font color = "silver">=</
font>&nbsp;<font color = "maroon">position</font>
<br><font color = "blue">FROM</font>&nbsp;&nbsp;&nbsp;<font color =
"maroon">msdb</font><font color = "silver">.</font><font color =
"silver">.</font><font color = "maroon">backupset</font>
<br><font color = "blue">WHERE</font>&nbsp;&nbsp;<font color =
"maroon">database_name</font>&nbsp;<font color = "silver">=</
font>&nbsp;<font color = "red">N'DB_Name__METABASE'</font>
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color =
"blue">AND</font>&nbsp;<font color = "maroon">backup_set_id</
font>&nbsp;<font color = "silver">=</font>&nbsp;<font color =
"silver">(</font><font color = "blue">SELECT</font>&nbsp;<font color =
"fuchsia"><b>MAX</font></b><font color = "silver">(</font><font color
= "maroon">backup_set_id</font><font color = "silver">)</font>
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font
color = "blue">FROM</font>&nbsp;&nbsp;&nbsp;<font color =
"maroon">msdb</font><font color = "silver">.</font><font color =
"silver">.</font><font color = "maroon">backupset</font>
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font
color = "blue">WHERE</font>&nbsp;&nbsp;<font color =
"maroon">database_name</font>&nbsp;<font color = "silver">=</
font>&nbsp;<font color = "red">N'DB_Name__METABASE'</font><font color
= "silver">)</font>

<br><br>
<font color = "blue">IF</font>&nbsp;<font color =
"#8000FF">@backupSetId</font>&nbsp;<font color = "blue">IS</
font>&nbsp;<font color = "blue">NULL</font>
<br>&nbsp;&nbsp;<font color = "blue">BEGIN</font>
<br>&nbsp;&nbsp;&nbsp;&nbsp;<font color = "blue">RAISERROR</
font>&nbsp;<font color = "silver">(</font><font color =
"red">N'Verify&nbsp;failed.&nbsp;Backup&nbsp;information&nbsp;for&nbsp;database&nbsp;''DB_Name__METABASE''&nbsp;not&nbsp;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>&nbsp;&nbsp;<font color = "blue">END</font>

<br><br>
<font color = "blue">RESTORE</font>&nbsp;<font color =
"maroon">verifyonly</font>&nbsp;<font color = "blue">FROM</
font>&nbsp;<font color = "maroon">disk</font>&nbsp;<font color =
"silver">=</font>&nbsp;<font color = "red">N'\\server\Backups
\DBServerName\\DB_Name__METABASE
\DB_Name__METABASE_backup_200610261158.bak'</font>&nbsp;<font color =
"blue">WITH</font>&nbsp;<font color = "blue">FILE</font>&nbsp;<font
color = "silver">=</font>&nbsp;<font color = "#8000FF">@backupSetId</
font>&nbsp;<font color = "silver">,</font>&nbsp;<font color =
"maroon">nounload</font>&nbsp;<font color = "silver">,</
font>&nbsp;<font color = "maroon">norewind</font>

<br><br>
<font color = "blue">GO</font>

<br><br>
<font color = "blue">BACKUP</font>&nbsp;<font color = "blue">DATABASE</
font>&nbsp;<font color = "maroon">[db_name__mscrm]</font>&nbsp;<font
color = "blue">TO</font>&nbsp;<font color = "maroon">disk</
font>&nbsp;<font color = "silver">=</font>&nbsp;<font color = "red">N'\
\server\Backups\DBServerName\\DB_Name__MSCRM
\DB_Name__MSCRM_backup_200610261158.bak'</font>&nbsp;<font color =
"blue">WITH</font>&nbsp;<font color = "maroon">differential</
font>&nbsp;<font color = "silver">,</font>&nbsp;<font color =
"maroon">noformat</font>&nbsp;<font color = "silver">,</
font>&nbsp;<font color = "maroon">noinit</font>&nbsp;<font color =
"silver">,</font>&nbsp;<font color = "maroon">name</font>&nbsp;<font
color = "silver">=</font>&nbsp;<font color =
"red">N'DB_Name__MSCRM_backup_20061026115839'</font>&nbsp;<font color
= "silver">,</font>&nbsp;<font color = "maroon">skip</font>&nbsp;<font
color = "silver">,</font>&nbsp;<font color = "maroon">rewind</
font>&nbsp;<font color = "silver">,</font>&nbsp;<font color =
"maroon">nounload</font>&nbsp;<font color = "silver">,</
font>&nbsp;<font color = "maroon">stats</font>&nbsp;<font color =
"silver">=</font>&nbsp;<font color = "black">10</font>

<br><br>
<font color = "blue">GO</font>

<br><br>
<font color = "blue">DECLARE</font>&nbsp;&nbsp;<font color =
"#8000FF">@backupSetId</font>&nbsp;&nbsp;<font color = "blue">AS</
font>&nbsp;<font color = "black">INT</font>

<br><br>
<font color = "blue">SELECT</font>&nbsp;<font color =
"#8000FF">@backupSetId</font>&nbsp;<font color = "silver">=</
font>&nbsp;<font color = "maroon">position</font>
<br><font color = "blue">FROM</font>&nbsp;&nbsp;&nbsp;<font color =
"maroon">msdb</font><font color = "silver">.</font><font color =
"silver">.</font><font color = "maroon">backupset</font>
<br><font color = "blue">WHERE</font>&nbsp;&nbsp;<font color =
"maroon">database_name</font>&nbsp;<font color = "silver">=</
font>&nbsp;<font color = "red">N'DB_Name__MSCRM'</font>
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color =
"blue">AND</font>&nbsp;<font color = "maroon">backup_set_id</
font>&nbsp;<font color = "silver">=</font>&nbsp;<font color =
"silver">(</font><font color = "blue">SELECT</font>&nbsp;<font color =
"fuchsia"><b>MAX</font></b><font color = "silver">(</font><font color
= "maroon">backup_set_id</font><font color = "silver">)</font>
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font
color = "blue">FROM</font>&nbsp;&nbsp;&nbsp;<font color =
"maroon">msdb</font><font color = "silver">.</font><font color =
"silver">.</font><font color = "maroon">backupset</font>
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font
color = "blue">WHERE</font>&nbsp;&nbsp;<font color =
"maroon">database_name</font>&nbsp;<font color = "silver">=</
font>&nbsp;<font color = "red">N'DB_Name__MSCRM'</font><font color =
"silver">)</font>

<br><br>
<font color = "blue">IF</font>&nbsp;<font color =
"#8000FF">@backupSetId</font>&nbsp;<font color = "blue">IS</
font>&nbsp;<font color = "blue">NULL</font>
<br>&nbsp;&nbsp;<font color = "blue">BEGIN</font>
<br>&nbsp;&nbsp;&nbsp;&nbsp;<font color = "blue">RAISERROR</
font>&nbsp;<font color = "silver">(</font><font color =
"red">N'Verify&nbsp;failed.&nbsp;Backup&nbsp;information&nbsp;for&nbsp;database&nbsp;''DB_Name__MSCRM''&nbsp;not&nbsp;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>&nbsp;&nbsp;<font color = "blue">END</font>

<br><br>
<font color = "blue">RESTORE</font>&nbsp;<font color =
"maroon">verifyonly</font>&nbsp;<font color = "blue">FROM</
font>&nbsp;<font color = "maroon">disk</font>&nbsp;<font color =
"silver">=</font>&nbsp;<font color = "red">N'\\server\Backups
\DBServerName\\DB_Name__MSCRM\DB_Name__MSCRM_backup_200610261158.bak'</
font>&nbsp;<font color = "blue">WITH</font>&nbsp;<font color =
"blue">FILE</font>&nbsp;<font color = "silver">=</font>&nbsp;<font
color = "#8000FF">@backupSetId</font>&nbsp;<font color = "silver">,</
font>&nbsp;<font color = "maroon">nounload</font>&nbsp;<font color =
"silver">,</font>&nbsp;<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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация