Database Journal
MS SQL Oracle DB2 Access MySQL PostgreSQL Sybase PHP SQL Etc SQL Scripts & Samples Tips Database Forum Rss Feed

» Database Journal Home
» Database Articles
» Database Tutorials
MS Access
SQL Scripts & Samples
» Database Forum
» Slideshows
Free Newsletters:

News Via RSS Feed

Rss Feed

Database Journal |DBA Support |SQLCourse |SQLCourse2

Featured Database Articles


Posted Sep 14, 1999

Check your backup strategy for SQL Server 7.0

By Sven Hammesfar

Do you have to review your backup strategy?

Information in this article applies to: Microsoft SQL Server Version 7.0

Microsoft SQL Server makes many tasks easier. Especially organizing the backup and recovery process has become much easier, because no devices have to be created and the database itself can also be rebuild automatically. 

if you plan to be able to recover your data up to the point of failure then be aware of some restrictions!


When you create a database you can specify one or more database and log files for the database. In SQL Server 7.0 every database uses at least 2 files: One for the data and one for the transaction log. With that in place you can backup the whole database and then continue with backing up the transaction logs.

In case of a failure in the data part you can save the latest transactions (that is all transactions that took place between the last backup and the point of failure) and then restore the first the data, then all previously saved logs and finally the changes that occured between the last backup (either database, incremental or log).

Sounds good, but your database has to follow a certain layout to make this possible. If you have a look in Books Online you'll find the following description for backing up the active part of the transaction log: 

Backing Up the Active Transaction Log

It is possible to back up the currently active transaction log even if the database is inaccessible, for example due to media failure, ...

Do not stop reading! The important part comes now:

... providing both the primary data file and the transaction log files are accessible.

So, if you want to maintain a system that can be restored up to the point of failure, you need at least three files:

  • The primary file in filegroup PRIMARY for all system objects.
  • One or more datafiles for table data, indexes and text data in filegroups other than PRIMARY
  • One or more transaction log files

What you should do

Create one or more filegroups for all the data part of your database. Make sure you put all tables, indexes and text data on this new filegroup. You can use ALTER DATABASE to make this new filegroup the default. That will make things easier.

Here is an example script for doing this:

USE master
/* Make Filegroup DATA the default filegroup in database Example: */
USE example
-- Check whether status has been updated in sysfilegroups:
SELECT groupname FROM sysfilegroups WHERE status  = 16


When you create new objects in Enterprise Manager, make sure you specify the correct filegroup. Enterprise Manager tends to put all objects on the PRIMARY filegroup even if you specified a different default filegroup.

Check the database for objects that have by accident been placed on the default filegroup. The following script will help you with this task:

PRINT 'The following objects are not set up for "POINT OF FAILURE" recovery:'

SELECT 'Warning' =
          WHEN i.indid < 2 THEN 'Table ' + o.name + 
                                     ' is located on the primary filegroup'
          WHEN i.indid = 255 THEN 'Text data of table ' 
               + o.name + 
               ' is located on the primary filegroup'
          ELSE 'Index ' + i.name + ' (Table ' + o.name 
               + ') is located on the primary filegroup'
        o.name as Tablename, 
        i.name as Indexname, 
        i.indid FROM sysfilegroups s 
          INNER JOIN sysindexes i
                ON s.groupid = i.groupid
                INNER JOIN sysobjects o
                      ON i.id = o.id
        WHERE o.type ='U' 
        AND s.groupname = 'PRIMARY'


If this scripts issues warnings, you should recreate the objects on a different filegroup (Enterprise Manager can here be helpful).

Now that you have got everything settled, plan your backup strategy. I suggest to include the following items.

  • Full backup (to start with)
  • Filegroup backups of PRIMARY and your own filegroups.
  • Regular transaction log backups

In case of a failure you can then recover up to the point of the failure:

Scenario 1: PRIMARY filegroup is damaged

Restore the filegroup backup and any transaction log backups you have

Could look like this:

-- First restore system tables from backup:
        FILE = 'Example_SYS',
        FROM DISK='G:\mssql7\backup\primary.bak'

-- Then restore the log backup.
RESTORE LOG Example FROM DISK='G:\mssql7\backup\log.bak'


This should bring your database back to a consistent state.


Scenario 2: Your data filegroup(s) become corrupt

Save the active part of the transaction log, specifying the NO_TRUNCATE option.


       TO DISK='G:\mssql7\backup\lastlog.bak' 

Then restore the database, logs and the final log that you have just saved.



6 rules you might find useful

  • Create at least three files/filegroups for every database
    (for System tables, User tables, Transaction log)
  • Do not store tables, indexes or text data on the primary filegroup
  • Make a filegroup other than PRIMARY the default filegroup for your database
  • Take care in Enterprise Manager when creating objects. EM usually defaults to PRIMARY when creating new objects
  • Use filegroup backup to backup the PRIMARY filegroup
  • Do not forget to backup the active part of the transaction log when your data filegroup(s) become damaged (WITH NO_TRUNCATE)

If you have any suggestions, comments concerning this article, please mail to sven hammesfahr.

MS SQL Archives

Latest Forum Threads
MS SQL Forum
Topic By Replies Updated
SQL 2005: SSIS: Error using SQL Server credentials poverty 3 August 17th, 07:43 AM
Need help changing table contents nkawtg 1 August 17th, 03:02 AM
SQL Server Memory confifuration bhosalenarayan 2 August 14th, 05:33 AM
SQL Server Primary Key and a Unique Key katty.jonh 2 July 25th, 10:36 AM