Skip to main content

Restore SQL Server database from multiple backup files

To restore a SQL server database from multiple files we can use the RESTORE DATABASE T-SQL command.

Before we do the restore process it is good to know the name of the “.mdf” and “.ldf” files in the backup set. To find this out we can run the RESTORE FILELISTONLY command in the following syntax:

RESTORE FILELISTONLY FROM

DISK = 'E:\Db_Backups\FILE1_FULL.BAK',

DISK = 'E:\Db_Backups\FILE2_FULL.BAK',

DISK = 'E:\Db_Backups\FILE3_FULL.BAK'

In the above example I assume the full backup consists of 3 files, “FILE1_FULL.BAK”, “FILE2_FULL.BAK”, and “FILE3_FULL.BAK”. The files in this case files are locate in E drive “Db_Backups” folder.

The above command will output the name of the “.mdf” and “.ldf” files contained in the backup set. Once we get those we can run the actual restore command in the following way:

RESTORE DATABASE My_DB FROM

DISK = 'E:\Db_Backups\FILE1_FULL.BAK',

DISK = 'E:\Db_Backups\FILE2_FULL.BAK',

DISK = 'E:\Db_Backups\FILE3_FULL.BAK'

WITH

MOVE My_DB ' TO 'E:\DATA\ My_DB.mdf',

MOVE My_DB _log' TO 'E:\LOGS\ My_DB _log.LDF',

STATS =1

Using the Move command we move the restored data and log files to a location of our choice and with STATS set as 1 we get a detailed verbose of the tasks happening similar to this:

1 percent processed.

2 percent processed.

3 percent processed.



100 percent processed.

Processed 108352 pages for database My_DB ', file My_DB ' on file 1.

Processed 5 pages for database ' My_DB ', file ' My_DB _log' on file 1.

RESTORE DATABASE successfully processed 108357 pages in 11.006 seconds (80.652 MB/sec).

When the database we try to restore does not exist and when the backup set is not a full backup, we receive the following error:

Msg 3118, Level 16, State 1, Line 1

The database " My_DB " does not exist. RESTORE can only create a database when restoring either a full backup or a file backup of the primary file.

Msg 3013, Level 16, State 1, Line 1

RESTORE DATABASE is terminating abnormally.

In this case we have to make sure we are using a Full backup to restore.

Comments

Popular posts from this blog

Users do not show up in SharePoint People Search or People Picker

I had this issue with people picker in a classic mode web application in SharePoint 2013 and this site is in 2010 mode - users in certain sub-domains would not show up in People Picker. I was aware of stsadm commands to fix this and we ran the stsadm command to hook up people picker with another domain some time back. The latest issue was that people picker was not returning users from the root domain and few sub domains. After researching on the internet I found (contrary to my thoughts) that we could use PowerShell and not just stsadm to map People Picker to domains. It is a good idea to first check what domains are added/mapped to the web application using the following commands: $wa = Get-SPWebApplication -Identity http://mywebapp.com #List the Domains $wa.PeoplePickerSettings.SearchActiveDirectoryDomains This will list the domains currently People Picker is looking up for that web application. I used the following script to map our AD forest to People Picker: ...

Page layout HTML changes not reflected in associated aspx

I had this issue for quite sometime with a SharePoint Online project I was working on. I use Design Manager to create a new layout page and add snippets to the html layout. I would create webpart zones, add my webpart snippets on to the html, save and publish but the resulting aspx page wouldn't have any of my webparts in it. I checked it from SPD 2013 and everything looks perfect, I can see all the code snippets in there. It was really strange and I had no clues. I had some content search webparts in the layout and one content editor webpart with a link to a text file with some css in it. After countless hours on the internet I read about few other people having similar issues when they had custom css on the layout pages to hide quick launch. I tried removing my content editor webpart and everything seems to be normal. A new page created using the layout had all the webparts in it and even the layout preview was displaying fine. I needed this css somewhere on the page and ...

Difference between the architectures of SSPs and SharePoint Service Application

SharePoint 2010 has some new features and components, which help to overcome difficulties such as redundancy and service-sharing that we faced while using SharePoint 2007.  Services in MOSS 2007 were implemented with the help of Shared Service Providers or SSPs. But we cannot use the services of one SSP for another SSP. So each SSP has to have its own set of services and applications, which increases redundant data in the farm.  For example, different managers in the same organization use a SharePoint site to maintain official data associated with an SSP. This SSP is associated with different services, such as Search service, BDC service, and a user profile service. A project manager in this organization requests an exclusive user profile service to maintain project data security. To provide this, we first need to create a separate SSP for the project manager and then a separate service called user profile service - project name. Next, we need to associate the SSP with ...