SQl Server : Backups

There are three types of backups:

  1. Full backup
  2. Differential backup
  3. Transaction log backup

Full backup

A full backup contains all the data in a specific database or set of file groups or files, and also enough log to allow for recovering that data. It is the base of both differential backup and transaction log backup.

Differential Backup

A “Differential” backup is a backup of any extent that has changed since the last “Full” backup was created.

Each time a new differential backup created it will contain every extent changed since the last full backup (NOT since the last differential backup).

When the database needs to be restored to the most recent time the user only need to restore the full backup and the most recent differential backup. All of the other differential backups can be ignored.

Transaction log backup

The transaction log is a serial record of all the transactions that have been performed against the database since the last transaction log back up.

With transaction log backups, you can recover the database to a specific point in time.
(see http://www.mssqltips.com/sqlservertutorial/119/sql-server-point-in-time-restore/)

Database should be set to “Full” or “Bulk-logged” recovery model for “Transaction Log” backups.

If the database is set to the “Bulk-logged” recovery model and a bulk operation was issued, then the entire transaction log needs to be restored.

A transaction log backup allows the user to back up the active part of the transaction log.  So after a “Full” or “Differential” backup the transaction log backup will have any transactions that were created after those other backups completed.  After the transaction log backup is issued, the space within the transaction log can be reused for other processes.  If a transaction log backup is not taken, the transaction log will continue to grow.

Reference:
http://www.mssqltips.com/sqlservertutorial/8/sql-server-transaction-log-backups/
http://www.todo-backup.com/backup-resource/sql-backup-software/sql-backup-types.htm
http://msdn.microsoft.com/en-us/library/ms187048.aspx

SQL Server : Bringing a database online from restoring or standby modes

If the database is in restoring state run the command below to bring the database online:

RESTORE DATABASE <Database Name> WITH RECOVERY


If the database is in read-only (standby) mode you can bring the database online in two steps

Step 01: Disconnect all the connections to the database
USE master
ALTER DATABASE <Database Name> SET OFFLINE WITH ROLLBACK IMMEDIATE
ALTER DATABASE <Database Name> SET ONLINE

Step 02: Bring the database online
RESTORE DATABASE <Database Name> WITH RECOVERY