when relevant content is
added and updated.
Now that you have objects created within your database, and data within the tables you need to secure your database in case of a server failure or accidental data deletion. This would be done by taking backups of the database. Backups are taken by using the BACKUP DATABASE command.
The frequency that full backups are taken at should be determined by how much data changes within the databases. On busier systems full backups should be taken daily. On systems which are less busy the full backup can be taken less often, every few days, once per week, etc.
The syntax of the BACKUP DATABASE command is fairly basic. You specify the name of the database to backup, and the destination that you will be backing up to. If your database name is MyDatabase and your going to backup to a file named MyDatabase.bak on the E drive your BACKUP DATABASE command would look something like this.
BACKUP DATABASE MyDatabase TO DISK='E:\MyDatabase.bak'
This command will backup all tables, views, procedures, functions, etc as well as all the data within the database. Backing up the database in an online operation meaning that users can be connected to the database, continuing to make changes to the database while the backup database command is running. The database is backed up in the same state that it was in when the command started. All changes made during the backup are logged into the database and staged in memory. Upon completion of the BACKUP DATABASE command these changes are destaged from memory to the physical file during a checkpoint operation.
If you have a full text index, and are using SQL Server 2000 the full text backup is not included as part of the backup which is created by the BACKUP DATABASE command. After restoring the database you would need to recreate the full text indexes. This issue is resolved in SQL Server 2005 when the full text indexes are added to the database backup.
If you wish to create two backups of the database so that your backups can survive a failure of the disk you backup the database to you can use the MIRROR TO clause of the BACKUP DATABASE command. This clause creates two exact duplicate backups of the database. This option is included in SQL Server 2005 and higher.
BACKUP DATABASE MyDatabase TO DISK='E:\MyDatabase.bak' MIRROR TO DISK='F:\MyDatabase.bak'
If you find that your backups are taking to long do to a large database size and/or slow disk speed on the disk you are backing up to you can strip the database backup across database backups. This is done by simply specifying additional destinations.
BACKUP DATABASE MyDatabase TO DISK='E:\Mydatabase.bak', DISK='F:\MyDatabase.bak'
Now striping your database can improve your backup performance, but it puts your backups at greater risk for a disk failure as each part of the backup disk is spread across two drives. If either backup file is lost or damaged the entire backup is useless. Because of this you can combine the striping for speed and the mirroring for safety. To do this the number of backup devices specified in the MIRROR clause must be the same as the number of backup devices specified in the initial destination clause.
BACKUP DATABAES MyDatabase TO DISK='E:\MyDatabase.bak', DISK='F:\MyDatabase.bak' MIRROR TO DISK='G:\MyDatabase.bak', DISK='H:\MyDatabase.bak'
You can read up more about detailed backup techniques in the eZine article I wrote a few months back.
Check back in the coming weeks for information about log backups and restoring your database and log backups.