Translate

Showing posts with label Restore. Show all posts
Showing posts with label Restore. Show all posts

Monday, May 27, 2013

Compress Backup Information in Backup and Restore Events

In SSMS, there is report called , “Backup and Restore Events” report.

image

if you consider latest backups backup size are almost similar. (~  339 MB) However, if you really see the physical file size, it is 79 MB.

So the report and physical file size is different.

You can measure the file size by running a query.

SELECT 
bs.media_set_id,
bs.backup_finish_date,
bs.type,
bs.backup_size / 1024 backup_size_KB,
bs.compressed_backup_size / 1024 compressed_backup_size_KB,
mf.physical_device_name
FROM dbo.backupset AS bs
INNER JOIN dbo.backupmediafamily AS mf
ON bs.media_set_id = mf.media_set_id
WHERE database_name = 'AdventureWorks2012'
ORDER BY backup_finish_date DESC;
GO

image


So , here you can see the correct value can be obtained you query compressed_backup_size column rather than querying backup_size column. so it seems like, SSMS report is using backup_size column rather than compressed_backup_size column which seems to be BUG!

Thursday, March 28, 2013

Database Restore Error

I was trying to restore a database, but was getting this error.

image

Error in text is, “the database principal is set as the execution context of one or more procedures functions.”

Error is getting after completion of 100% and after searching few web pages, it seems like a security or schema error. These are few of those links.

The database principal is set as the execution context of one or more procedures ... - MSDN – Mi

Microsoft SQL Server- The database principal is set as the execution

Drop failed for user

However, none of these links were relevant after I verify all schemas.

Then there was thought came to check the error logs and found this error in the error log.

Database 'XXXX' was restored, however an error was encountered while replication was being restored/removed. The database has been left offline. See the topic MSSQL_ENG003165 in SQL Server Books Online

This is the BOL link for it. http://msdn.microsoft.com/en-us/library/ms151782(v=sql.90).aspx

This error is raised if a problem occurs restoring a backup of a replicated database:

The error is probably the result of a mismatch between the state of the restored database and one or more system databases that contain replication metadata: msdb, master, or the distribution database.

Execute ALTER DATABASE to bring the database online; for example: ALTER DATABASE AdventureWorks SET ONLINE. For more information, see ALTER DATABASE (Transact-SQL). If you want to preserve replication settings, go to step 2. If not, go to step 3.

Also, you can restore the database with KEEP_REPLICATION option as well.

Saturday, July 21, 2012

Restoring to Existing Database

If you want to restore to the existing databases, first you need to make sure that database is not accessible by any other users. So you need to change the database into single user mode before restoring.

However, in SQL Server 2012 you have this option inbuilt with the restoring option.

image

Wednesday, July 18, 2012

Thursday, May 31, 2012

Differential Backups for System Databases

There was a question in www.sqlservercentral.com asking what the system database you can’t take differential backups.

My initial thought was it is tempdb as I couldn’t see a reason why you need take differential backups in tempdb. Also, msdb and model you might need to take the differential backups and in master database you should be able to take differential backups since it has user information.

But the answer is master. Confused smile

Then I thought of digging further into this.

1. Is this true?

image

Yes it is. If you go through the backup UI , you will only see Full backup option under master database while for all the other system databases you will see Full and Differential backup option.

2. Why?

I was wondering why is this since I can’t see a logic behind this. However, it is very simple. Smile with tongue out

What is the mechanism to restore differential backups.

  1. Restore the Full backup with NORECOVERY option on.
  2. Then Restore the differential backup.

So if you want restore differential backup of a master database, first you need to restore full back with NORECOVERY option. which you CANNOT do for master database. Since you can’t do that there is no point of taking a differential backups.