Tuesday, 11 February 2020

SQL Server Backup and Restore Strategy Step by Step


Who is not aware of a SQL Database? It was the first business language introduced for E.F Codd’s Relational Database management system. In addition, MySQL, Oracle, Informix, Sybase, MS Access-all use SQL as the standard database query language. For such a vast application, INTEGRITY and SAFETY tasks become the crucial ones. In order to secure censorious data stored in our SQL Server databases, the SQL Server backup and restore component gives an essential safeguard for it. To lessen the risk of calamitous data loss, we need to back up our databases to preserve modifications and adaptions to our data on a regular basis. A prudent backup and restore strategy helps protecting databases against data loss caused by a variety of failures. 

Why we need Backup?

Having a backup of necessary data is the only way to keep the data protected.
  • By having a backup of our precious data, means to store copies of data in a safe, off-site location that secures us from potentially disastrous data loss.
With valid backups of a database, you may recover your data from the number of failures, such as:
  1. Encountering a Media failure.
  2. Running into user errors, for instance, dropping a table/row by mistake.
  3. Hardware failures, for instance, a damaged disk drive or permanent loss of a server.
  4. Running across natural calamities.
By applying SQL-Server Backup to Azure Blob storage service, you may make an off-site backup in a various region than your on-premises location, to use in the event of a natural disaster affecting your on-premises location.
  • Additionally, backups of a database are also convenient for routine administrative objects, such as making a copy of the database from one server to another, setting up Always On availability groups or database mirroring, and archiving. 


Backup Options:
  1. Differential-back-up, A data-backup that is based on the latest full backup of comprehension or partial database (the differential base) and that consists only the data that has elaborated since that base.
  2. Full backup A data-backup that includes all the data in a specific database and also enough log to allow for recovering that data.
  3. Log-backup, A backup of transaction logs that include all log records that were not backed-up in a previous log backup. (full recovery model)

Backup and restore strategies

A well-designed backup and restore strategy stabilize the business requirements for utmost data availability and reduced data loss, while considering the cost of maintaining and storing backups.
A backup and restore strategy hold a backup portion and a restore portion. The backup part of the approach defines:
  • The type and recurrence of backups
  • The nature & speed of the hardware that is needed for them
  • How backups are to be tested and evaluated.
  • Where and how back-up media is to be stored
The restore part of the strategy defines: 
  • Who is responsible for acting restores?
  • How restores must be executed to fulfill your dreams for database availability and lowering information loss.
  • How restores are tested and evaluated.
Scheming an effective backup and restore strategy needs careful planning, implementation, and testing. Testing is important: you do not have a backup strategy until you have efficiently restored backups in all the combinations that are included in your restore strategy and have tested the restored database for physical consistency. You must acknowledge a variety of factors. These include:

  • The goals of your organization concerning your production databases, specifically the requirements for availability and protection of information from loss or harm.
  • The nature of each database: its size, its usage patterns, the character of its content material, the requirements for its information, and so forth.
  • Constraints on resources, such as: hardware, employees, space for storing backup media, the bodily security of the stored media, and so on.
Here is the process to restore database from backup:
  • Here, we have 2 databases connected with server.

  • Right click on the DB and select Restore option as shown in figure:

  • Click Ok

Recovery Models
To start with, SQL Server comes up with three restoration models. The restoration model is a configurable database property that defines how the transactions are logged and the way the database is fall back. They include:
  1. Simple Recovery Mode: It is the simplest recovery model. Transactional log backups are not allowed and so recovery cannot be done for a point in time.
  2. Full Recovery Mode: Transactional log backups are allowed and so recovery is done for a point in time. It encourages minimal data loss and it should be preferred in production-type databases.
  3. Bulk-Logged Recovery Mode: This mode is best used when there are bulk-transactions occurring (e.g., nightly/monthly cycle) in databases. Full Recovery Mode can be directed to Bulk-Logged during the bulk-transactions and retrogressed during normal data activity.

Customizing a database-backup and healing process to the requirements of the organization may be very essential. Each organization has exclusive requirements for amount of data, acceptable data loss, and acceptable restoration time frames. Determining these for your organization will help you to choose the appropriate backup and restore options and to be prepared during any unforeseen situation that causes any system or database failures. Careful planning will help the limit data loss and reduce downtime during such occurrences.