Database Research & Development

  • Home
  • NoSQL
    • NoSQL
    • Cassandra
  • Databases
    • Database Theory
    • Database Designing
    • SQL Server Coding Standards
    • SQL Server
    • PostgreSQL
    • MySQL
    • Greenplum
    • Linux
  • Interviews
    • SQL Server Interviews
    • MySQL Interviews
    • SQL Puzzles
  • DBA Scripts
    • SQL Server DBA Scripts
    • PostgreSQL DBA Scripts
    • MySQL DBA Scripts
    • Greenplum DBA Scripts
  • Home
  • Blog Archives !
  • (: Laugh@dbrnd :)
  • Contact Me !
sqlserverinterviews
Home 2016 May SQL Server: Database Backup & Restore Interview Questions and Answers (Day-5)

SQL Server: Database Backup & Restore Interview Questions and Answers (Day-5)

This article is half-done without your Comment! *** Please share your thoughts via Comment ***

How to turn off logging of all successful backups in your SQL Server error logs?

Using trace flag 3226.

1
DBCC TRACEON (3226,-1)

T-SQL script to take a database backup.

1
BACKUP DATABASE AdventureWorks2012 TO DISK='e:\advwork.bak'

Backup to multiple files using T-SQL.

1
2
3
4
BACKUP DATABASE AdventureWorks2012 TO
DISK='e:\advwork.bak'
,DISK='d:\advwork.bak'
,DISK='f:\advwork.bak'

T-SQL script to restore a database.

1
RESTORE DATABASE AdventureWorks2012 FROM DISK='e:\advwork.bak'

T-SQL script to set RECOVERY FULL model.

1
ALTER DATABASE dbrnd_DB SET RECOVERY FULL;

T-SQL script to take Database Log backup.

1
BACKUP LOG dbrnd_DB TO DISK = 'd:\dbrnd\dbrnd_tran01.trn'  WITH retaindays = 3

T-SQL script to restore a multiple transaction log backups.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
RESTORE DATABASE AdventureWorks2012
FROM AdventureWorks2012_1
WITH NORECOVERY;
GO
 
RESTORE LOG AdventureWorks2012
FROM AdventureWorks2012_log
WITH FILE = 1,
NORECOVERY;
GO
 
RESTORE LOG AdventureWorks2012
FROM AdventureWorks2012_log
WITH FILE = 2,
WITH NORECOVERY;
GO
 
RESTORE LOG AdventureWorks2012
FROM AdventureWorks2012_log
WITH FILE = 3,
WITH NORECOVERY;
GO
 
RESTORE DATABASE AdventureWorks2012
WITH RECOVERY;
GO

Consider a situation where database backup size is 80 GB and you have three different disks and each has 30 GB free space.

Now the question is, can you split your database backups?

Yes, it is possible. We can split the backup files into different places and the same can be restored.

1
2
3
4
5
6
7
8
9
BACKUP DATABASE AdventureWorks
TO DISK = ‘D:\AdventureWorks1.bak’,
DISK = ‘E:\AdventureWorks2.bak’,
DISK = ‘F:\AdventureWorks3.bak’
 
RESTORE DATABASE [AdventureWorks]
FROM DISK = ’D:\Backup\MultiFile\AdventureWorks1.bak’,
DISK = ’E:\AdventureWorks2.bak’,
DISK = ’F:\AdventureWorks3.bak’

We have configured every Sunday 11pm FULL backup. Every 11pm differential backups and every 1h.r transaction log backups.

The Database was failed at 11.30 pm on Friday. Then what are the database recovery steps?

  • Take Tail log backup to get 11-11.30pm transactions on Friday.
  • Restore last Sunday full backup with NO_RECOVERY.
  • Restore Friday 11pm differential backup with NO_RECOVERY.
  • Restore tail log backup with RECOVERY.

What is File or File Group backup?

Using the file or filegroup backup you can backup an entire filegroup or files within the filegroup. These backups are essential when the database size is so large that backups must be done in parts because it takes too long to backup the entire database.

T-SQL Script to take File Group backup.

1
2
BACKUP DATABASE AdventureWorks2012 FILEGROUP='PRIMARY', FILEGROUP ='Secondary'
TO DISK ='D:\AdventureWorks2012_FileGroup.bak'

What is Mirrored backup?

Mirrored database backups can be used to create multiple copies of the database backups on different locations.

T-SQL Script to take Mirrored backup.

1
2
3
BACKUP DATABASE AdventureWorks2012
TO DISK = ‘C:\AdventureWorks2012.bak’
MIRROR TO DISK = ‘D:\AdventureWorks2012_mirror.bak’

What is a log chain?

A continuous sequence of log backups is called a log chain. A log chain starts with a full backup of the database. Usually, a new log chain is only started when the database is backed up for the first time or after the recovery model is switched from simple recovery to full or bulk-logged recovery.

Is it possible in any situation when differential backup grows more than the Full backup?

Yes, it is possible in case when you do not take Full backup of the database for months and change in the databases grow more than the size of the Full backup.

Is it mandatory to take a Full backup if we switch the recovery model of a database?

Yes, It is mandatory to take a Full backup of the database after switching the recovery model of the database to initiate the log chain. Otherwise Diff. or Transaction logs will fail.

What is the below error?

Msg 3023, Level 16, State 2, Line 1

Backup and file manipulation operations (such as ALTER DATABASE ADD FILE) on a database must be serialized. Reissue the statement after the current backup or file manipulation operation is completed.

This error occurs when we try to run a backup, shrink, or alter database command in SQL Server in parallel.

Can you take differential backup of Master Database?

No, differential backup of master database is not allowed.

Can you take backup of a database which is in emergency mode?

We can’t take the database backup if the database is in emergency mode.

SQL Server has native backup. Why pay money for a tool to do it?

SQL Server backups work extremely well, but you’re going to have to do some work to get them set up and even more to get them automated.

A good third party product will make this automation process very simple.

For example, some tools more efficient at compressing backups, saving even more disk space and time during your backup processes.

May 22, 2016Anvesh Patel
SQL Server: Database Backup & Restore Interview Questions and Answers (Day-4)SQL Server: Database Backup & Restore Interview Questions and Answers (Day-6)
Anvesh Patel
Anvesh Patel

Database Engineer

May 22, 2016 SQL Server InterviewAnvesh Patel, backup, database, database research and development, dbrnd, Interviews, restore, SQL Query, SQL Server, SQL Server Administrator, SQL Server Monitoring, SQL Server Performance Tunning, SQL Server Tips and Tricks, TSQL
About Me!

I'm Anvesh Patel, a Database Engineer certified by Oracle and IBM. I'm working as a Database Architect, Database Optimizer, Database Administrator, Database Developer. Providing the best articles and solutions for different problems in the best manner through my blogs is my passion. I have more than six years of experience with various RDBMS products like MSSQL Server, PostgreSQL, MySQL, Greenplum and currently learning and doing research on BIGData and NoSQL technology. -- Hyderabad, India.

About DBRND !

dbrnd

This is a personal blog (www.dbrnd.com).

Any views or opinions represented in this blog are personal and belong solely to the blog owner and do not represent those of people, institutions or organizations that the owner may or may not be associated with in professional or personal capacity, unless explicitly stated.

Feel free to challenge me, disagree with me, or tell me I’m completely nuts in the comments section of each blog entry, but I reserve the right to delete any comment for any reason whatsoever (abusive, profane, rude, or anonymous comments) - so keep it polite.

The content of this website is protected by copyright. No portion of this website may be copied or replicated in any form without the written consent of the website owner.

Recent Comments !
  • Anvesh Patel { Sure will do... } – May 27, 12:43 PM
  • Anvesh Patel { Great... } – May 27, 12:41 PM
  • Anvesh Patel { Great... } – May 27, 12:39 PM
  • Anvesh Patel { Great... } – May 27, 12:36 PM
  • Anvesh Patel { Great... } – May 27, 12:28 PM
  • Anvesh Patel { Great... } – May 27, 12:27 PM
  • Anvesh Patel { Great... } – May 27, 12:16 PM
  • Older »
Follow Me !
  • facebook
  • linkedin
  • twitter
  • youtube
  • google
  • flickr
© 2015 – 2019 All rights reserved. Database Research & Development (dbrnd.com)
Posting....