How to Backup SQL Server Database?

Yatendra Singh    Yatendra Singh     Updated On - 24 Apr 2019

SQL Server Database contains data that is of critical importance for every other organization. So, organizations are highly protective about it and are prepared for worst case scenarios, and high-risk data loss situations.

Considering the importance of the SQL database, it is recommended to create database file backup to stay ready and prepared for the darkest phase of database file corruption and damage events.

Otherwise, searching for methods regarding how to restore SQL Server database or tips to recover SQL database from suspect mode will become the only task with the highest priority in your to-do list. And doing so is not an easy job, as the inefficiency of native Microsoft applications leaves you with nothing but a handful of features that are only useful if the database files are accessible by the user, (and are not corrupt or damaged).

In this article, we will guide you on how to backup SQL Server database using different tools and will also discuss the importance of differential backups and provide a demonstration on how to create SQL Server differential backup, followed by the essentials of backing up the data and files.

Backup Essentials

General practice of creating backups is important especially when data is the key factor for the business. Doing so saves from the hassle of fixing things and finding ways for recovering what is already lost.

To understand the importance of creating backups, below are a few points elaborated:

  • Protection from Power Failures
  • Computer systems are prone to damage due to power outages, and this affects all the unsaved files and folders including the live & running instance of SQL Server database. Also, the hard drive can turn inaccessible because of such uncontrolled activity, making every piece of information stored on the drive locally, out of reach. Therefore, backup is the only thing that remains in your court to get things back to normal.

  • Safety from Virus Attacks
  • It’s nothing new that files and folders affected by viruses remain no longer accessible, and after multiple trials of accessing the affected files and folders, the virus spreads throughout the system. In the case of database files, virus attacks aren’t something to be considered differently. One should also worry about the problem of SQL injections. File backups allow faster recovery and restoration of files lost or damaged due to various reasons like virus attacks.

  • Recovery from Operating System Failures
  • One of the reasons behind data loss, file corruption and damage out of many is the operating system crash. Why it happens, cannot be stated on the ground of certainty, but the causes behind can be many such as, outdated build, resource overloading, software corruption, improper memory allocation, system application errors, and more. In most cases, the user would have to reinstall the operating system. Thus all files and data stored locally on the hard-drive will be gone, in case if no backups are there.

  • Quick File and Data Recovery
  • Creating file or folder backups is not only an essential thing but also a good practice that assures that meaningful data won’t go anywhere no matter how worse the situation is. With backups, it becomes easy, fast, and convenient to retrieve the data.

Backup SQL Server Database on a Disk Device Using Transact SQL

The list of benefits associated to backups can go long but above given are few to get you started, and now that you know the perks of creating file backups, let’s proceed to create the SQL Server database backup.

Follow the steps given below to create SQL Server Database using Transact SQL on a disk device:

Note: Backups created using an earlier or later version of SQL Server can’t be restored using the other version of the software.

USE TechForums19;

GO

BACKUP DATABASE TechForums19
TO DISK = ‘Z:\SQLServerBackups\TechForums19.Bak’
WITH FORMAT,
MEDIANAME = ‘Z_SQLServerBackups’,
NAME = ‘Full Backup of TechForums19’,

GO

Note: Above, TechForums19, is the database selected for backup, change it with the one you want to back up.

Backup SQL Server Database Using PowerShell

To create the SQL Server database backup using PowerShell, we’ll use the Backup-SqlDatabase cmdlet, and to create the full database backup, we’ll specify the optional -BackupAction parameter with its default value, which is Database.

Execute the below PowerShell command to create the full SQL Server Database backup:

Backup-SqlDatabase -ServerInstance Computer/Instance –Database TechForums19 –BackupAction Database

Note: Above example, demonstrates the full database backup of a SQL Server Database, where Computer/Instance is the backup location of the server instance. Again, replace TechForums19 with your SQL Server database name.

Differential Backups a Good Practice Why?

Whenever creates a full SQL Server database backup, there are a few things that one should consider such as, creating full database backups is a lengthy and time-consuming task. If the database file size it large, it will require more storage to keep it.

Create SQL Server Differential Backup

Follow below steps to create the differential backup of a SQL Server Database:

Example showing both the full SQL Server database backup and differential backup:

BACKUP DATABASE TechForums19
TO TechForums19_DB
WITH INIT;

–Initiate the differential backup after a change, or an update is made on the select SQL Server database.

GO

BACKUP DATABASE TechForums19
TO TechForums19_DB
WITH DIFFERENTIAL;

GO
Example showing only the differential backup:
GO

Note: Make sure that you’ve created the full SQL Server database backup already; otherwise, the differential backup cannot be initiated.

When the SQL Backups Fail

Above are the methods to help you create full SQL Server database backups and Differential Backups. File backups are there to help you get out of database corruption situations but what to do when even the backup files turn corrupt or get damaged. In that case, you have two options:

  • To fight the issue of SQL Server database file (MDF and NDF file) corruption and damage, use an SQL Recovery tool.
  • To restore SQL Server database file (MDF and NDF file) from corrupt or damaged SQL backup files, use an SQL Backup Recovery tool.

Kernel for SQL Backup Recovery is made to fix corruption and damage issues in SQL Backup files. It restores MDF/NDF files from .bak files to live SQL Server/Batch file.

Follow the steps below for the data restoration from healthy/corrupt/damaged database backup (BAK) file.

  1. Open Kernel for Backup Recovery.
  2. Click on Browse button to select the BAK (database backup) file and click Next.

    Note: If the database backup file (BAK) is highly corrupt or damaged then, select Advanced Scan instead of Standard Scan.
  3. After the database file scan completion, the tool’s UI will display all the data on the screen.
    Click on + Icon to expand and collapse the database objects listed in a tree format (in the left side).

    Note: By clicking on each object, you can generate an item preview to ensure data integrity.
  4. In this step, select the SQL Server option to restore the data from database backup file to live SQL Server instance. Input server credentials and server authentication details, as shown below and click Ok.

    Note: You can also, save the restored data in a batch file; for doing so select the Batch File radio option; select the BAK file and click Open.
  5. Wait until the process completes.

    Note: If you wish to stop the restoration process, click on the Stop button.
  6. Done, click Ok.

You have successfully restored the data from SQL Server database backup (BAK) file.

Wrap

Creating file backups is not only a good practice but also insurance which saves time and money. And Kernel for SQL Database Recovery is there to fix the issues, when the database files turn corrupt, and you wonder how to repair corrupt SQL database. It is a one-stop-shop for SQL repair & recovery. Alternately, you can restore SQL database files even from damaged SQL backup files using Kernel SQL Backup Recovery tool.