<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Backup &amp; Recovery - Techyaz.com</title>
	<atom:link href="https://techyaz.com/category/sql-server/backup-recovery/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>Tips, Tutorials and How-to Topics</description>
	<lastBuildDate>Fri, 23 Jul 2021 12:04:48 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8</generator>

<image>
	<url>https://techyaz.com/wp-content/uploads/2017/11/cropped-Site-icon-150x150.png</url>
	<title>Backup &amp; Recovery - Techyaz.com</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Restore a Database Participating in Alwayson Availability Group</title>
		<link>https://techyaz.com/sql-server/alwayson/restore-database-participating-alwayson-availability-group/</link>
					<comments>https://techyaz.com/sql-server/alwayson/restore-database-participating-alwayson-availability-group/#comments</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Wed, 31 Jan 2018 10:39:33 +0000</pubDate>
				<category><![CDATA[AlwaysOn]]></category>
		<category><![CDATA[Backup & Recovery]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[availability group]]></category>
		<category><![CDATA[Backups]]></category>
		<category><![CDATA[restore]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=1687</guid>

					<description><![CDATA[<p>Sometimes, we need to restore a database that is part of always on availability group to fulfill our business needs. There might be several reasons behind doing this. Restore a database in availability group is different than restoring a normal&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/restore-database-participating-alwayson-availability-group/">Restore a Database Participating in Alwayson Availability Group</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Sometimes, we need to restore a database that is part of always on availability group to fulfill our business needs. There might be several reasons behind doing this. Restore a database in availability group is different than restoring a normal database. <img decoding="async" class="size-full wp-image-1698 alignright" src="http://techyaz.com/wp-content/uploads/2018/01/Restore-a-database-in-Availability-Group.png" alt="Restore a database in Availability Group" width="200" height="200" srcset="https://techyaz.com/wp-content/uploads/2018/01/Restore-a-database-in-Availability-Group.png 200w, https://techyaz.com/wp-content/uploads/2018/01/Restore-a-database-in-Availability-Group-150x150.png 150w, https://techyaz.com/wp-content/uploads/2018/01/Restore-a-database-in-Availability-Group-160x160.png 160w, https://techyaz.com/wp-content/uploads/2018/01/Restore-a-database-in-Availability-Group-320x320.png 320w" sizes="(max-width: 200px) 100vw, 200px" />You cannot restore Availability Group database directly as you do for other databases. You will get below error message while doing this.</p>
<p><span style="color: #ff0000;"><em>The operation cannot be performed on database “DBNAME” because it is involved in a database mirroring session or an availability group. Some operations are not allowed on a database that is participating in a database mirroring session or in an availability group.</em></span></p>
<p>As per above error details, we cannot restore a database that is part of always on availability group directly. Here, I will explain step by step process to restore such databases.</p>
<h3><span style="color: #333399;">Restore Databases in Availability Group</span></h3>
<p>If you need to restore an availability group database, you need to first evict that database from availability group and then restore that database and finally you can re-add it to the always on availability group. So, there are three steps involved in restoring an AOAG database.</p>
<ol>
<li>Remove identified database from Availability Group.</li>
<li>Restore that database.</li>
<li>Add database to Availability Group post restore operation.</li>
</ol>
<p>Let&#8217;s explain each steps in detail in order to restore an alwayson database.</p>
<h5><span style="color: #333399;">Remove Database from Availability Group</span></h5>
<p>First step is to remove the identified database from AOAG configuration to restore AOAG database. If you have to restore primary database in AOAG configuration then you should remove it from the primary replica that will automatically remove this database from AOAG configuration on secondary replica as well. You don’t need to separately remove secondary database from AOAG configuration. We can use below T-SQL statement to remove your primary database from AOAG configuration.</p>
<pre><span style="color: #0000ff;"><strong><span style="color: #008000;">--Change name of AG_Techyaz to your Availability group.
--Change database name from Techyaz to your primary database.</span>
ALTER AVAILABILITY GROUP AG_Techyaz REMOVE DATABASE Techyaz
</strong></span></pre>
<p>You can use GUI method as well to remove primary database from AOAG configuration. Read attached article to understand step by step process to<strong> <a href="http://techyaz.com/sql-server/remove-database-always-availability-group/" target="_blank" rel="noopener">remove a database from Availability group using GUI method.</a></strong></p>
<h5><span style="color: #333399;">Restore Database</span></h5>
<p>Once primary database will be removed from availability group, It will disappear from Availability Database folder showing under your Availability group name on both replicas. Now, next step will be database restore. Go ahead to restore your database.<br />
Here, we have to restore our database till 25 Jan 8 AM to<strong> <a href="http://techyaz.com/sql-server/point-in-time-recovery/" target="_blank" rel="noopener">recover point in time data</a></strong>. You can use your backup files as per your requirement. You can use either GUI method  in SSMS or T-SQL method to restore your database. Run below command to restore this database.</p>
<pre><span style="color: #008000;"><strong>--Restore primary database with the help of your backup file.</strong></span>
<span style="color: #0000ff;"><strong>RESTORE DATABASE Techyaz
FROM Disk= ‘F:\Backups\Techyaz_Full.bak’
WITH NORECOVERY, REPLACE;

<span style="color: #008000;">--Restore log backup till the time you want to recover the database.</span></strong></span>
<span style="color: #0000ff;"><strong>RESTORE LOG Techyaz
FROM Disk= ‘F:\Backups\Techyaz_TLog.trn’
WITH NORECOVERY, REPLACE, STOPAT = 'Jan 25, 2018 8:00 AM';

<span style="color: #008000;">--Bring database Online.</span></strong></span>
<span style="color: #0000ff;"><strong>RESTORE DATABASE Techyaz WITH RECOVERY;
</strong></span></pre>
<p>Once your database will be restored and comes online, we will go ahead to add this database to availability group again.</p>
<h5><span style="color: #333399;">Add database to Availability Group</span></h5>
<p>If you want to re-add this database to availability group then you must perform this step otherwise your database will not have any HA or DR capability. I would recommend to first prepare your corresponding secondary database before starting to add it to availability group. If you have a plan to prepare secondary database during adding it to availability group then the processing will take lot of time for huge databases.</p>
<p>To prepare the secondary database, you first need to take a<strong> <a href="http://techyaz.com/sql-server/understanding-sql-server-backups/" target="_blank" rel="noopener">full backup</a></strong> and immediate transaction log backup of your newly restored primary database. Copy these files to secondary replica and restore corresponding secondary database in norecovery mode. Below are high level steps you need to perform to add this database to AOAG configuration.</p>
<ol>
<li>Run full backup and immediate transaction log backup of primary database on primary replica.</li>
<li>Copy both full backup and log backup files to secondary replica.</li>
<li>Restore corresponding secondary database with the help of above copied files in norecovery mode with REPLACE option.</li>
<li>Now, run below T-SQL command to add this database to existing availability group. If you want to<strong> <a href="http://techyaz.com/sql-server/add-database-availability-group/" target="_blank" rel="noopener">add this database to existing AOAG configuration using GUI method</a></strong> in SSMS, visit attached link where I have described it in step by step process.</li>
</ol>
<pre style="padding-left: 30px;"><span style="color: #0000ff;"><strong><span style="color: #008000;">-- Connect to the server instance that hosts the primary replica.
-- Add an existing database to the availability group.</span>
ALTER AVAILABILITY GROUP AG_Techyaz ADD DATABASE Techyaz;
GO
</strong></span></pre>
<p>Make sure to configure your secondary database on secondary replica as we have done from step 1 to step 3.<br />
If you don’t want to add this database to availability group then you can ignore this step and use your database for transactions. You can also remove its corresponding database that is in restoring state on secondary replica. If you want to use that database from secondary replica for any purpose you can bring it online by running below command on secondary replica.</p>
<pre><span style="color: #008000;"><strong>--Run on secondary replica in case you don't want to configure this database in AOAG rather want to use it for transactions.
<span style="color: #0000ff;">RESTORE DATABASE Techyaz WITH RECOVERY;
</span></strong></span></pre>
<p>Now, you are done with database restore in Alwayson Availability Group. Validate it by launching dashboard report or looking in to SSMS to get AOAG health for newly added or restored database.<br />
I hope you like this article. Please comments us and follow our <a href="https://www.facebook.com/Techyaz/">facebook</a> page and <a href="https://twitter.com/Tech_yaz">Twitter</a> handle to get latest updates.</p>
<p><span style="color: #800000;"><em><strong>Read More:</strong></em></span></p>
<ul>
<li><strong><a href="http://techyaz.com/sql-server/sql-server-administration/understanding-sql-server-backup-databases-availability-group/" target="_blank" rel="noopener">Understanding Backup Preferences in Alwayson Availability Group</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/alwayson/fix-aoag-listener-error-19471-kerberos-status-showing-handle-invalid/" target="_blank" rel="noopener">AOAG Listener Error 19471: The handle is Invalid</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/troubleshooting/secondary-replica-not-coming-online-showing-resolving-state-automatic-failover-alwayson-availability-group-configuration/" target="_blank" rel="noopener">Secondary Replica Showing in Resolving State after AOAG Automatic Failover</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/troubleshooting/fix-error-976/" target="_blank" rel="noopener">Fix Error 976: Cannot Connect to Secondary Replica</a></strong></li>
</ul>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/restore-database-participating-alwayson-availability-group/">Restore a Database Participating in Alwayson Availability Group</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/alwayson/restore-database-participating-alwayson-availability-group/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>Fix SQL Server Error 3023: Shrink failed for LogFile &#8220;Log File Name&#8221;</title>
		<link>https://techyaz.com/sql-server/fix-error-3023-error-3013-error-3041/</link>
					<comments>https://techyaz.com/sql-server/fix-error-3023-error-3013-error-3041/#comments</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Mon, 20 Nov 2017 12:48:01 +0000</pubDate>
				<category><![CDATA[Backup & Recovery]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Administration]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[Autoshrink]]></category>
		<category><![CDATA[Backups]]></category>
		<category><![CDATA[HowTO]]></category>
		<category><![CDATA[Shrink]]></category>
		<category><![CDATA[SQL_Error_Code]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=1175</guid>

					<description><![CDATA[<p>Today, I got below Microsoft SQL Server error 3023 when I was trying to manually shrink a log file. The error details are given below: Shrink failed for LogFile &#8216;Logfile_Name&#8221;. Backup, file manipulation operations (such as ALTER DATABASE ADD FILE)&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/fix-error-3023-error-3013-error-3041/">Fix SQL Server Error 3023: Shrink failed for LogFile &#8220;Log File Name&#8221;</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Today, I got below Microsoft SQL Server error 3023 when I was trying to manually shrink a log file. The error details are given below:</p>
<p><span style="color: #ff0000;"><em>Shrink failed for LogFile &#8216;Logfile_Name&#8221;.</em><br />
<em>Backup, file manipulation operations (such as ALTER DATABASE ADD FILE) and encryption changes on a database must be serialized. Reissue the statement after the current backup or file manipulation operation is completed. (Microsoft SQL Server, Error: 3023)</em><br />
</span><br />
Here is the screenshot of this error:</p>
<p><img fetchpriority="high" decoding="async" class="aligncenter size-full wp-image-1176" src="http://techyaz.com/wp-content/uploads/2017/11/Error-3023.jpg" alt="error 3023" width="608" height="203" srcset="https://techyaz.com/wp-content/uploads/2017/11/Error-3023.jpg 608w, https://techyaz.com/wp-content/uploads/2017/11/Error-3023-300x100.jpg 300w" sizes="(max-width: 608px) 100vw, 608px" /></p>
<p>We get this error when there is a conflict between <a href="https://techyaz.com/sql-server/understanding-sql-server-backups/" target="_blank" rel="noopener">backup operation</a> and <a href="https://techyaz.com/sql-server/always-turn-off-database-auto-shrink/" target="_blank" rel="noopener">Shrink operation</a>. SQL Server are designed to follow some rules during Backup and Shrink operations. These are given below:</p>
<ol>
<li>We can run only one database backup at a time. When a full database backup occurs, differential or incremental backups cannot occur at the same time.</li>
<li>Only one log backup can happen at a time. A log backup is allowed when a full database backup is occurring.</li>
<li>You cannot add or drop files to a database while a backup is occurring.</li>
<li>You cannot shrink files while database backups are happening.</li>
<li>There are limited recovery model changes allowed while backups are occurring.</li>
</ol>
<p>When any of these conflicting operations are performed, the commands will be receiving the SQL Server error 3023, SQL Server error 3013 and SQL Server error 3041 messages.</p>
<p>You might also get below error when you perform another database backup if backup is already running for your database.</p>
<p><em><span style="color: #ff0000;">Msg 3013, Level 16, State 1, Line 1<br />
BACKUP DATABASE is terminating abnormally.</span></em></p>
<p>Or if you try to run a differential backup for a database for which full backup is already running, you will get below error code:</p>
<p><em><span style="color: #ff0000;">Backup Error: 3041, Severity: 16, State: 1.<br />
BACKUP failed to complete the command BACKUP DATABASE MyDatabase WITH DIFFERENTIAL. Check the backup application log for detailed messages.</span></em></p>
<p>Solution to fix such issues is to examine the schedules of the various database maintenance activities, and then adjust the schedules so that these operations or commands do not conflict with each other.</p>
<p>Make sure to not run any operation that will conflict with each other. If you get such errors check your SQL Server Agent jobs and wait till that job will be completed. In my case, database backup was running while I was trying to shrink a log file. I did wait for some time and then tried again to shrink that file and this time SQL Server allowed me to run this shrink operation.</p>
<p>Here, i have explained how to fix Microsoft SQL Server error 3023,  error 3013 and error 3041. I hope you like this article. Please follow our <a href="https://www.facebook.com/Techyaz/">Facebook</a> page and <a href="https://twitter.com/Tech_yaz">Twitter </a>handle to get latest updates.</p>
<p>The post <a href="https://techyaz.com/sql-server/fix-error-3023-error-3013-error-3041/">Fix SQL Server Error 3023: Shrink failed for LogFile &#8220;Log File Name&#8221;</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/fix-error-3023-error-3013-error-3041/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>SQL Server Backup &#038; Recovery Interview Questions &#038; Answers</title>
		<link>https://techyaz.com/interview-questions/sql-server-interview-questions/sql-server-backup-recovery-interview-questions-answers/</link>
					<comments>https://techyaz.com/interview-questions/sql-server-interview-questions/sql-server-backup-recovery-interview-questions-answers/#comments</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Wed, 11 Oct 2017 20:22:27 +0000</pubDate>
				<category><![CDATA[Backup & Recovery]]></category>
		<category><![CDATA[Interview Questions]]></category>
		<category><![CDATA[SQL Server Interview Questions]]></category>
		<category><![CDATA[Interview]]></category>
		<category><![CDATA[recovery]]></category>
		<category><![CDATA[restore]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=1054</guid>

					<description><![CDATA[<p>This article is based on SQL Server backup &#38; recovery interview questions and answers. You can access SQL Server Architecture based interview questions and General DBA related interview questions in attached links. Feel free to counter on any point that is&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/interview-questions/sql-server-interview-questions/sql-server-backup-recovery-interview-questions-answers/">SQL Server Backup &#038; Recovery Interview Questions &#038; Answers</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>This article is based on SQL Server backup &amp; recovery interview questions and answers. You can access <a href="http://techyaz.com/interview-questions/sql-server-interview-questions-answers-architecture/" target="_blank" rel="noopener">SQL Server Architecture based interview questions</a> and <a href="http://techyaz.com/interview-questions/sql-server-dba-interview-questions-answers/" target="_blank" rel="noopener">General DBA related interview questions</a> in attached links. Feel free to counter on any point that is not correct or where you are not agree. We will discuss and love to hear your expert advise. You can access <strong><a href="http://techyaz.com/category/interview-questions/sql-server-interview-questions/" target="_blank" rel="noopener">All SQL Server Interview Questions and Answers</a></strong> on different topics in attached link.</p>
<h3><span style="color: #333399;">SQL Server Backup &amp; Recovery Interview Questions</span></h3>
<p><strong>Question-</strong> <strong>What is Minimal Logging and how is it different from Full Logging?</strong></p>
<p><strong>Answer-</strong> Minimal logging involves logging only information that is required to recover the transaction without supporting <a href="http://techyaz.com/sql-server/point-in-time-recovery/" target="_blank" rel="noopener">point-in-time recovery</a>. Under the <a href="http://techyaz.com/sql-server/understanding-sql-server-recovery-model/" target="_blank" rel="noopener">full recovery model</a>, all bulk operations are fully logged. However, you can minimize logging for a set of bulk operations by switching the database to the <a href="http://techyaz.com/sql-server/understanding-sql-server-recovery-model/" target="_blank" rel="noopener">bulk-logged recovery model</a> temporarily for bulk operations.</p>
<p>Minimal logging is more efficient than full logging, and it reduces the possibility of a large-scale bulk operation filling the available <a href="http://techyaz.com/sql-server/understanding-transaction-log-architecture/" target="_blank" rel="noopener">transaction log</a> space during a bulk transaction. However, if the database is damaged or lost when minimal logging is in effect, you cannot recover the database to the point of failure.</p>
<p><img decoding="async" class="wp-image-1059 alignleft" src="http://techyaz.com/wp-content/uploads/2017/10/Interview_QuestionsAnswers-300x284.jpg" alt="" width="378" height="358" srcset="https://techyaz.com/wp-content/uploads/2017/10/Interview_QuestionsAnswers-300x284.jpg 300w, https://techyaz.com/wp-content/uploads/2017/10/Interview_QuestionsAnswers.jpg 716w" sizes="(max-width: 378px) 100vw, 378px" /></p>
<p><strong>Question-</strong> <strong>Can you name few operations that logs Minimally during bulk-recovery model?</strong></p>
<p><strong>Answer-</strong> The following operations, which are fully logged under the full recovery model, are minimally logged under bulk-logged recovery model:</p>
<ol>
<li>Bulk import operations (bcp, BULK INSERT, and INSERT&#8230; SELECT).</li>
<li>SELECT INTO operations</li>
<li>CREATE INDEX operations</li>
<li>ALTER INDEX REBUILD or DBCC DBREINDEX operations.</li>
<li>DROP INDEX new heap rebuild</li>
</ol>
<p><strong>Question- If I change my database recovery model from FULL to SIMPLE, does transactions will be logged in to log file?</strong></p>
<p><strong>Answer-</strong> Yes, Transactions will be logged in SIMPLE recovery model as well. The difference is all logged transactions will be cleared during checkpoint operation in this recovery model. Read more about <a href="http://techyaz.com/sql-server/checkpoint/" target="_blank" rel="noopener">Checkpoint operations</a> &amp; <a href="http://techyaz.com/sql-server/understanding-sql-server-recovery-model/" target="_blank" rel="noopener">SQL Server Recovery Models</a>.</p>
<p><strong>Question-</strong> <strong>If yes in above question then how is SIMPLE RECOVERY Model different from FULL Recovery Model?</strong></p>
<p><strong>Answer-</strong> All logged transactions will be cleared during checkpoint operation and transaction log backup is not allowed so point-in-time recovery is not possible in SIMPLE recovery model. Whereas transaction backup is allowed in full recovery model and point-in-time recovery is also supported. Logs got cleared only after taking log backup or switching the recovery model to SIMPLE.</p>
<p><strong>Question-</strong> <strong>Can we achieve point-in-time recovery in Bulk-logged Recovery Model?</strong></p>
<p><strong>Answer-</strong> Yes, if there is no bulk operation performed on your database and you have all log backups. Point-in-time recovery is not possible if your recovery point falls falls in-between any bulk operations. .</p>
<p><strong>Question-</strong> <strong>How differential backup works?</strong> <strong>or</strong></p>
<p><strong>How differential backup captures only updated data since full backup in its dump file?</strong></p>
<p><strong>Answer-</strong> <a href="http://techyaz.com/sql-server/understanding-sql-server-data-files-pages-extents/" target="_blank" rel="noopener">Differential Changed Map</a> is a page type that stores information about extents that have changed since the last full backup. Database engine reads just the DCM pages to determine which extents have been modified and captures those extents in differential backup file.</p>
<p><strong>Question-</strong> <strong>Why cannot we serve copy-only backup  as a differential base or differential backup?</strong></p>
<p><strong>Answer-</strong> The differential changed map page is not updated by a <a href="http://techyaz.com/sql-server/understanding-sql-server-backups/" target="_blank" rel="noopener">copy-only backup</a>. Therefore, a copy-only backup cannot serve as a differential base or differential backup. A copy-only backup does not affect subsequent differential backups.</p>
<p><strong>Question-</strong> <strong>Why a database log file is growing like anything that is running in <a href="http://techyaz.com/sql-server/understanding-sql-server-recovery-model/" target="_blank" rel="noopener">SIMPLE Recovery Model</a>?</strong></p>
<p><strong>Answer-</strong> It means some transactions are active and running on your database.  As we know logs are captured in simple recovery model as well so that active transaction is getting logged there. The inactive portion in log file clears during checkpoint operation.</p>
<p><strong>Question- Can we restore a database till the specific time?</strong></p>
<p><strong>Answer-</strong> Yes, if database is running in full recovery model and database has log backups till that specific time. We can use STOPAT clause to recover till a specific time.</p>
<p><strong>Question-</strong> <strong>Suppose we are running Daily full backup at 8PM in night and every half an hour transaction log backup. Now your database is crashed at 3.41PM. How will you recover your database to the point it was crashed?</strong></p>
<p><strong>Answer- </strong>Below steps we will perform in a sequence manner to recover this database to the point it was crashed.</p>
<ul>
<li>First we will run <strong>tail log backup</strong> to capture all transactions that are not captured in previous log backups at the point database was crashed.</li>
<li>Restore last night<strong> Full backup</strong> with NORECOVERY that was taken at 8PM.</li>
<li>Apply <strong>all transaction log backup since last night full backup</strong> with norecovery.</li>
<li>Apply <strong>tail log backup</strong> on the database with recovery and with <strong>STOPAT</strong> parameter.<strong> </strong></li>
</ul>
<p><strong>Question- Take the same scenario as above, now you found that there is one log file let’s say at 2 PM got corrupted and not restorable. What will be the impact on your database recovery?</strong></p>
<p><strong>Answer-</strong>  We cannot recover this database till that point it was crashed and we would have last data till 1.30PM considering log backup runs on every half an hour.</p>
<p><strong>Question-</strong> <strong>Suppose we are running Weekly Sunday full backup at 8PM, daily differential backup at 10PM and every half an hour transaction log backup. Now your database is crashed on Saturday 3.11PM. What would be your fastest way to recover this database in point in time?</strong></p>
<p><strong>Answer-  </strong>We will perform below steps to recover this database in point-in-time:</p>
<ol>
<li>Try to run <strong>tail log backup</strong> at the point database was crashed.</li>
<li>Restore latest Weekly <strong>Sunday Full backup</strong> with NORECOVERY that was taken at 8PM.</li>
<li>Restore <strong>Friday night differential backup</strong> with NORECOVERY that was taken at 10PM.</li>
<li>Apply <strong>all transaction log backup since Friday differential backup</strong> with norecovery.</li>
<li>Apply <strong>tail log backup</strong> on the database with recovery and with <strong>STOPAT</strong> parameter.<strong> </strong></li>
</ol>
<p><strong>Question-</strong> <strong>In addition to above question, suppose you came to know that Friday night differential backup was corrupted then what would be your strategy to recovery the database in point-in time?</strong></p>
<p><strong>Answer- </strong>We will perform below steps to recover this database in point-in-time:</p>
<ol>
<li>Try to run <strong>tail log backup</strong> at the point database was crashed.</li>
<li>Restore latest Weekly <strong>Sunday Full backup</strong> with NORECOVERY that was taken at 8PM.</li>
<li>Restore <strong><span style="color: #ff0000;">Thursday </span>night differential backup</strong> with NORECOVERY that was taken at 10PM.</li>
<li>Apply <strong>all transaction log backup since <span style="color: #ff0000;">Thursday</span> night differential backup</strong> with norecovery.</li>
<li>Apply <strong>tail log backup</strong> on the database with recovery and with <strong>STOPAT</strong> parameter.<strong> </strong></li>
</ol>
<p><strong>Question-</strong> <strong>Suppose you came to know that differential backups ran on Monday and Wednesday are corrupted and you have only Tuesday and Thursday differential backups along with full backup and all log backups. Explain your sequence to restore the database?</strong></p>
<p><strong>Answer-</strong> We will follow same sequence that we follow in previous question. We will apply weekly full backup then Thursday differential backup along with all transaction log backups.</p>
<p><strong>Question-</strong> <strong>How will you restore tempdb?</strong></p>
<p><strong>Answer-</strong> We should not restore tempdb as it’s a temporary database and created everytime we restart SQL Server service.</p>
<p><strong>Question-</strong> <strong>What is COPY_ONLY full backup and how it is different from regular full backups?</strong></p>
<p><strong>Answer-</strong> Difference between regular full and copy-only full backup is that copy-only full backup does not break the differential chain. Neither of them breaks the log chain as neither of them truncates the log file. A copy-only backup cannot serve as a differential base or differential backup and does not affect the differential base.</p>
<p>Please Like, Share and comment us about your feedback. I hope you like this article. You can comment your questions in below section. Please follow our <a href="https://www.facebook.com/Techyaz/">facebook page</a> and <a href="https://twitter.com/Tech_yaz">Twitter </a>handle to get latest updates.</p>
<p><span style="color: #800000;"><em><strong>Read More Interview Q&amp;A:</strong></em></span></p>
<ul>
<li><strong><a href="http://techyaz.com/sql-server/alwayson/sql-server-alwayson-interview-questions-answers/" target="_blank" rel="noopener">SQL Server Interview Q&amp;A on Alwayson Availability Group</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/sql-server-interview-questions-answers-indexes/" target="_blank" rel="noopener">SQL Server Interview Q&amp;A on Indexes</a></strong></li>
</ul>
<p>The post <a href="https://techyaz.com/interview-questions/sql-server-interview-questions/sql-server-backup-recovery-interview-questions-answers/">SQL Server Backup &#038; Recovery Interview Questions &#038; Answers</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/interview-questions/sql-server-interview-questions/sql-server-backup-recovery-interview-questions-answers/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>Understanding Backup Preferences for AlwaysOn Availability Group Databases</title>
		<link>https://techyaz.com/sql-server/alwayson/understanding-sql-server-backup-databases-availability-group/</link>
					<comments>https://techyaz.com/sql-server/alwayson/understanding-sql-server-backup-databases-availability-group/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Thu, 21 Sep 2017 06:53:07 +0000</pubDate>
				<category><![CDATA[AlwaysOn]]></category>
		<category><![CDATA[Backup & Recovery]]></category>
		<category><![CDATA[SQL Server Administration]]></category>
		<category><![CDATA[AOAG]]></category>
		<category><![CDATA[availability group]]></category>
		<category><![CDATA[Backups]]></category>
		<category><![CDATA[HADR]]></category>
		<category><![CDATA[HowTO]]></category>
		<category><![CDATA[T-SQL]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=943</guid>

					<description><![CDATA[<p>We know SQL Server Backups are resource intensive operation that strain on I/O and CPU (with backup compression). AlwaysOn Availability Group has very good capability to offload SQL Server backups and read operations from primary replica to reduce such workloads&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/understanding-sql-server-backup-databases-availability-group/">Understanding Backup Preferences for AlwaysOn Availability Group Databases</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>We know <a href="https://techyaz.com/sql-server/understanding-sql-server-backups/" target="_blank" rel="noopener">SQL Server Backups</a> are resource intensive operation that strain on I/O and CPU (with backup compression). <a href="https://techyaz.com/sql-server/alwayson-availability-group/" target="_blank" rel="noopener">AlwaysOn Availability Group</a> has very good capability to offload SQL Server backups and read operations from primary replica to reduce such workloads and utilize secondary replicas in a better way. Read this article to understand backup preferences for AOAG databases.</p>
<p>Before going ahead, we need to understand the rules/points that are very important in order to decide the backup preferences in AOAG configuration. Below are the important points you should consider during designing backup strategy of availability databases.</p>
<ul>
<li>Regular <strong>Full Backups</strong> are not allowed from secondary replicas. Only <a href="https://techyaz.com/sql-server/understanding-sql-server-backups/" target="_blank" rel="noopener">COPY_ONLY full backups</a> are allowed on secondary replicas. That means you cannot run regular Full backup from any of the secondary replica. Remember that copy-only backups do not impact the log chain or clear the differential bitmap.</li>
<li><strong>Differential backups</strong> are not supported on secondary replicas. If you must run differential backups for your availability databases, you should not choose backup preferences as secondary replicas.</li>
<li>Only regular <strong>Log backups</strong> are supported on secondary replicas. COPY_ONLY log backups are not supported on secondary replicas.</li>
<li>Secondary replica must be in <strong>SYNCHRONIZED </strong>or <strong>SYNCHRONIZING </strong>state to backup a secondary database.</li>
<li>Log backup chain is supported across all replicas regardless of where the log backup is taken (primary or secondary replicas) or the mode of the replication (asynchronous or synchronous).</li>
<li>In a distributed availability group, backups can be performed on secondary replicas in the same availability group as the active primary replica, or on the primary replica of any secondary availability groups.</li>
</ul>
<h5><span style="color: #000080;">How SQL Server Decides Which Replica will execute Backup &#8211; Backup Preferences ?</span></h5>
<p>It’s little complex process to determine where backup jobs should run.  If you are confused about this question, then keep reading to get the answer.</p>
<p>To decide on which replica, you should run your backup job depends on your <strong>Backup Preferences</strong> setting. To address this, configure the availability group to specify which availability replicas where you would prefer backups to be performed.</p>
<p>If you choose backup preferences as <strong>secondary only</strong> then you can create jobs on only secondary replicas or if you choose to run it on <strong>primary replica</strong>, then you can configure it on primary replica only. But if you decided to go with default option that is <strong>preferred secondary</strong> then you should schedule backup jobs on all replicas.  Although, Microsoft suggests to create scripted backup-jobs for every availability database on every server instance that hosts an availability replica that is a candidate for performing backups.</p>
<p>Suppose you have chosen <strong>secondary only</strong> preference and you have 3 secondary replicas then question might arise how database engine will decide that on which replica backup should run. Database engine decides where should run backup based on <strong>preferred backup replica</strong> settings and <strong>backup priority</strong> settings. I have explained about these settings later in this article.</p>
<p>AOAG (AlwaysOn Availability group) has a function named <strong>sys.fn_hadr_backup_is_preferred_replica</strong>  to determine which replica is set as preferred backup replica.  If the out of this function returns 1 it means current instance is the preferred backup replica and backup will run on this instance. If returns 0, it means backup will not run on that replica.  We can use this function in a backup script to determine job should run on which replica, so only one of the scheduled jobs actually proceeds to the backup stage.</p>
<p>In the event of a failover, none of the scripts or jobs needs to be modified. Also, if you reconfigure an availability group to add an availability replica, managing the backup job requires simply copying or scheduling the backup job. If you remove an availability replica, simply delete the backup job from the server instance that hosted that replica. Microsoft has given a sample code logic for this function that can be used to develop backup script.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span style="color: #0000ff;">If sys.fn_hadr_backup_is_preferred_replica( @dbname ) &lt;&gt; 1
BEGIN</span>
<span style="color: #008000;">-- If this is not the preferred replica, exit (probably without error).</span>
<span style="color: #0000ff;">END</span>
<span style="color: #008000;">-- If this is the preferred replica, continue to do the backup.
</span></strong></pre>
<p>If you use the Maintenance Plan Wizard to create a given backup job, the job will automatically include the scripting logic that calls and checks the <strong>sys.fn_hadr_backup_is_preferred_replica</strong> function.</p>
<p>If you want to check the preferred backup replica for any availability database, you can get it by running below command. If the output of this function returns 1 it means current instance is the preferred backup replica and backup will run on this instance. If returns 0, it means backup will not run on that replica.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span style="color: #008000;">--Get the backup preference replica for availability database TechYaz.</span>
<span style="color: #0000ff;">SELECT sys.fn_hadr_backup_is_preferred_replica ('TechYaz');
GO
</span></strong></pre>
<p>I have executed same function on my secondary replica. You can see the output is showing as 1, it means this replica is set to run backups.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-944" src="http://techyaz.com/wp-content/uploads/2017/09/1-backup-replica.jpg" alt="Get preferred backup replica" width="461" height="172" srcset="https://techyaz.com/wp-content/uploads/2017/09/1-backup-replica.jpg 461w, https://techyaz.com/wp-content/uploads/2017/09/1-backup-replica-300x112.jpg 300w" sizes="auto, (max-width: 461px) 100vw, 461px" /></p>
<h5><span style="color: #000080;">Configure Backup of Availability Databases to Run only from Secondary Replicas using GUI</span></h5>
<ol>
<li>Connect to the server instance that hosts the primary replica, and click the server name to expand the server tree. You would not be able to change Backup Preferences from any secondary replicas. If you open the AOAG name property, you will find all options greyed out.</li>
<li>Expand the <strong>Alwayson High Availability </strong>node and the <strong>Availability Groups</strong></li>
<li>Click the availability group whose backup preferences you want to configure, and select the <strong>Properties.</strong></li>
<li>In the <strong>Availability Group Properties </strong>dialog box, select <strong>Backup Preferences</strong> You can see backup preference is set to <strong>Prefer Secondary</strong>, now we need to change it to <strong>Secondary only </strong>option<strong>.</strong> The details about each type of backup preference is given in the screenshot and AOAG backup preference property window.</li>
</ol>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-946" src="http://techyaz.com/wp-content/uploads/2017/09/3-AOAG-property-from-Primary.jpg" alt="AOAG Property Window" width="705" height="637" srcset="https://techyaz.com/wp-content/uploads/2017/09/3-AOAG-property-from-Primary.jpg 705w, https://techyaz.com/wp-content/uploads/2017/09/3-AOAG-property-from-Primary-300x271.jpg 300w" sizes="auto, (max-width: 705px) 100vw, 705px" /></p>
<ol start="5">
<li>There are 4 backup preferences in AOAG that are given below with their capabilities. Choose any as per your requirements. Now I will add one more replica to this availability group as per our requirement and set backup preference to secondary only so that backups always run from either of the both secondary replicas. It is not mandatory for you to add additional replica.</li>
</ol>

<table id="tablepress-3" class="tablepress tablepress-id-3">
<thead>
<tr class="row-1">
	<th class="column-1">Backup Preference</th><th class="column-2">Backup Runs on</th><th class="column-3">Remarks</th>
</tr>
</thead>
<tbody class="row-striping row-hover">
<tr class="row-2">
	<td class="column-1">Prefer Secondary</td><td class="column-2">Secondary Replica</td><td class="column-3">Default Option. You cannot run differential backup in this option. If only Primary Replica is online, backup will run on Primary Replica.</td>
</tr>
<tr class="row-3">
	<td class="column-1">Secondary only</td><td class="column-2">Only Secondary Replicas</td><td class="column-3">Backup will never run on Primary Replica. If only Primary Replica is online, backup will not run. You cannot run differential backup in this option as well.</td>
</tr>
<tr class="row-4">
	<td class="column-1">Primary</td><td class="column-2">Primary Replica</td><td class="column-3">Choose this option if you want to run differential backup.</td>
</tr>
<tr class="row-5">
	<td class="column-1">Any Replica</td><td class="column-2">Can run on any replica based on backup priority of each availability replica in combination with its operational state and connected state.</td><td class="column-3">Set backup priority carefully between replicas.</td>
</tr>
</tbody>
</table>

<ol start="6">
<li>Use the <strong>Replica backup priorities</strong> grid to change the <strong>backup priority</strong> of the availability replicas. <strong>Backup Priority</strong> (Lowest=1, Highest=100) specifies your priority for performing backups on this replica relative to the other replicas in the same availability group. In my case backup will run on the replica that has priority 60% and if this will not be available then backup will run on the replica that has priority of 50%. Backup will never run on primary replica irrespective of backup priority settings because we have chosen to run backups only on secondary replica.<br />
<img loading="lazy" decoding="async" class="aligncenter size-full wp-image-947" src="http://techyaz.com/wp-content/uploads/2017/09/4-AOAG-property-from-Primary.jpg" alt="Availability group property Window" width="701" height="635" srcset="https://techyaz.com/wp-content/uploads/2017/09/4-AOAG-property-from-Primary.jpg 701w, https://techyaz.com/wp-content/uploads/2017/09/4-AOAG-property-from-Primary-300x272.jpg 300w" sizes="auto, (max-width: 701px) 100vw, 701px" /><br />
We have also an option Exclude Replica to exclude any replica where you don’t want to run backups. This is useful for remote availability replicas to which you never want to run backups there.<br />
You should click on checkbox for your respective replica name for which you want to exclude the backup as shown in above screenshot.</li>
</ol>
<ol start="7">
<li>Click on OK button to apply the changes.</li>
</ol>
<h5><span style="color: #000080;">Configure SQL Server Backup in AOAG to Run with default backup preference using T-SQL</span></h5>
<p>I have shown you how to change backup preference setting to run backups from secondary replicas using GUI. We can do the same using T-SQL commands as well. Here i will show you how to change backup preference using T-SQL. As we have changed the backup preference to secondary only option where backups will never run from primary replica. Now we can revert this change to default option using T-SQL. <strong>Prefer Secondary</strong> is default option in which backups run from secondary replica and if only primary replica is online then it will run from primary replica only.</p>
<p>Connect to the server instance that hosts the primary replica and run below command.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span style="color: #008000;">--Choose backup preference as per your choice and pass that value in AUTOMATED_BACKUP_PREFERENCE = { PRIMARY | SECONDARY_ONLY| SECONDARY | NONE }</span>
<span style="color: #0000ff;">ALTER AVAILABILITY GROUP AG_AOAGName SET (AUTOMATED_BACKUP_PREFERENCE = SECONDARY)
GO
</span></strong></pre>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-948" src="http://techyaz.com/wp-content/uploads/2017/09/5-t-sql.jpg" alt="Change backup preference using T-sql" width="606" height="151" srcset="https://techyaz.com/wp-content/uploads/2017/09/5-t-sql.jpg 606w, https://techyaz.com/wp-content/uploads/2017/09/5-t-sql-300x75.jpg 300w" sizes="auto, (max-width: 606px) 100vw, 606px" /></p>
<p>Now your backup preference would be set to <strong>Prefer Secondary</strong> and backups will run from primary replica if only primary replica will be online.</p>
<p><em><span style="color: #800000;"><strong>Related Articles:</strong></span></em></p>
<ul>
<li><span style="color: #0000ff;"><strong><a style="color: #0000ff;" href="https://techyaz.com/sql-server/troubleshooting/secondary-replica-not-coming-online-showing-resolving-state-automatic-failover-alwayson-availability-group-configuration/" target="_blank" rel="noopener">Fix: Secondary Replica Stucked in to Resolving state</a></strong></span></li>
<li><span style="color: #0000ff;"><strong><a style="color: #0000ff;" href="https://techyaz.com/sql-server/troubleshooting/fixing-sap-connectivity-issue-aoag-automatic-failover/" target="_blank" rel="noopener">Fix: Connectivity Issue after AOAG Automatic Failover</a></strong></span></li>
<li><span style="color: #0000ff;"><strong><a style="color: #0000ff;" href="https://techyaz.com/sql-server/understanding-sql-server-recovery-model/" target="_blank" rel="noopener">Understanding SQL Server Recovery Models</a></strong></span></li>
<li><span style="color: #0000ff;"><strong><a style="color: #0000ff;" href="https://techyaz.com/sql-server/troubleshooting/fix-error-19471-listener-issue-that-came-during-configuring-sql-server-alwayson-availability-group/" target="_blank" rel="noopener">Fix: Listener Issue Error 19471</a></strong></span></li>
</ul>
<p>I hope you like this article. Please follow us on our <a href="https://www.facebook.com/Techyaz/">facebook page</a> and on <a href="https://twitter.com/Tech_yaz">Twitter </a>handle to get latest updates.</p>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/understanding-sql-server-backup-databases-availability-group/">Understanding Backup Preferences for AlwaysOn Availability Group Databases</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/alwayson/understanding-sql-server-backup-databases-availability-group/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Understanding SQL Server Backups</title>
		<link>https://techyaz.com/sql-server/backup-recovery/understanding-sql-server-backups/</link>
					<comments>https://techyaz.com/sql-server/backup-recovery/understanding-sql-server-backups/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Tue, 12 Sep 2017 07:14:28 +0000</pubDate>
				<category><![CDATA[Backup & Recovery]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Administration]]></category>
		<category><![CDATA[Backups]]></category>
		<category><![CDATA[recovery]]></category>
		<category><![CDATA[restore]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=838</guid>

					<description><![CDATA[<p>SQL Server Backups are the dump of its databases that can be used to recover them in case of any corruption, outage or emergency. Backups are essential for data protection. We run SQL Server backups to safeguard our databases from&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/backup-recovery/understanding-sql-server-backups/">Understanding SQL Server Backups</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>SQL Server Backups are the dump of its databases that can be used to recover them in case of any corruption, outage or emergency. Backups are essential for data protection. We run SQL Server backups to safeguard our databases from user errors, media failure, hardware failure etc. There are multiple types of backups available in SQL Server.</p>
<ul>
<li>Full Backup</li>
<li>Differential Backup</li>
<li>Transaction Log Backup</li>
<li>Copy-Only Backup</li>
<li>File Backup</li>
<li>Partial Backup</li>
</ul>
<h3><span style="color: #000080;">Full Backup</span></h3>
<p>Full database backup captures dump of whole database including transaction logs. Full backup is supported in all three <a href="https://techyaz.com/sql-server/understanding-sql-server-recovery-model/" target="_blank" rel="noopener">recovery models</a>. Below is T-SQL script that can be used to run a full backup of SQL Server database.</p>
<pre><strong><span style="color: #008000;">-- Back up the TechYaz database to new media set.</span></strong>
 <strong> <span style="color: #0000ff;">BACKUP DATABASE TechYaz</span></strong>
 <strong><span style="color: #0000ff;"> TO DISK = 'D:\Backups\TechYaz_25Aug2017.bak'</span></strong>
 <strong><span style="color: #0000ff;"> WITH FORMAT;</span></strong>
 <strong><span style="color: #0000ff;"> GO</span></strong></pre>
<h3><span style="color: #000080;">Differential Backup</span></h3>
<p>A differential backup depends on the most recent full database backup. A differential backup captures only the data that has changed since that full backup. If your database does not have any full backup yet, you will not be able to run its differential backup. A base full backup is required to run the differential backup. Differential backup is faster because it does not capture full database dump but only the extents that are updated since last full backup.  Database engine reads details about updated extents from <a href="https://techyaz.com/sql-server/understanding-sql-server-data-files-pages-extents/" target="_blank" rel="noopener">Differential Changed Map</a> page type and capture those page ids only into the backup.  Read more about these page types on attached article. Differential backup can be used in all recovery models. Below is T-SQL script that can be used to run a differential backup of SQL Server database.</p>
<pre><strong><span style="color: #008000;">-- Create a full database backup first by running above commands.</span></strong>
 <strong><span style="color: #008000;"> -- Create a differential database backup</span></strong>
 <strong> <span style="color: #0000ff;">BACKUP DATABASE TechYaz</span></strong>
 <strong><span style="color: #0000ff;"> TO DISK= 'D:\Backups\TechYaz_25Aug2017.drn'</span></strong>
 <strong><span style="color: #0000ff;"> WITH DIFFERENTIAL;</span></strong>
 <strong><span style="color: #0000ff;"> GO</span></strong></pre>
<h3><span style="color: #000080;">Transaction Log Backup</span></h3>
<p>Transaction log backup works only in full and bulk-logged recovery model. We cannot run log backup in <a href="https://techyaz.com/sql-server/understanding-sql-server-recovery-model/" target="_blank" rel="noopener">simple recovery model</a>. We must have at least a full database backup to run transaction log backup. If full backup is not performed since the database creation, log backup cannot be executed. We should frequently run log backup to minimize work loss exposure and to truncate the <a href="https://techyaz.com/sql-server/understanding-transaction-log-architecture/" target="_blank" rel="noopener">transaction log</a> that make free space in database log file. Run below T-SQL code to run log backup.</p>
<pre><strong><span style="color: #008000;">-- Create a full database backup first.</span></strong>
 <strong><span style="color: #008000;"> -- Create a log database backup by running below command.</span></strong>
 <span style="color: #0000ff;"><strong> BACKUP LOG TechYaz</strong></span>
 <span style="color: #0000ff;"><strong> TO DISK = 'D:\Backups\TechYaz_25Aug2017.trn'</strong></span>
 <span style="color: #0000ff;"><strong> GO</strong></span></pre>
<h3><span style="color: #000080;">Copy Only Backup</span></h3>
<p>A copy-only backup is independent of the sequence of conventional SQL Server backups. It is just like conventional full backup without affecting the sequence of existing backup chain. Usually, taking a backup changes the database and affects how later backups are restored. However, occasionally, it is useful to take a backup for a special purpose without affecting the overall backup and restore procedures for the database. Copy-only backups serve this purpose. There are two types of copy-only backups.</p>
<ul>
<li>Copy-only full backup</li>
<li>Copy-only transaction log backup</li>
</ul>
<p>You cannot use copy-only full backup as a differential backup base. It means you cannot run differential backup considering copy only full backup as its base neither you can restore any differential backup on top of copy only full backup. A copy-only log backup preserves the existing log archive point and, therefore, does not affect the sequencing of regular log backups. The transaction log is never truncated after a copy-only backup.<br />
Copy-only backups are recorded in the is_copy_only column of the backupset table. Below T-SQL can be used to run copy only backups.</p>
<pre><strong><span style="color: #008000;">--Run Copy-Only Full backup</span></strong>
 <strong> <span style="color: #0000ff;">BACKUP DATABASE TechYaz</span></strong>
 <strong><span style="color: #0000ff;"> TO DISK = 'D:\BACKUP\TechYaz_25Aug2017_Copy.bak'</span></strong>
 <strong><span style="color: #0000ff;"> WITH COPY_ONLY;</span></strong>

<strong><span style="color: #008000;">--Run Copy-Only Log backup</span></strong>
 <strong> <span style="color: #0000ff;">BACKUP LOG TechYaz</span></strong>
 <strong><span style="color: #0000ff;"> TO DISK = 'D:\Backup\TechYaz_25Aug2017_LogCopy.trn'</span></strong>
 <strong><span style="color: #0000ff;"> WITH COPY_ONLY;</span></strong></pre>
<h3><span style="color: #000080;">File Backup</span></h3>
<p>As per Book Online, A full file backup backs up all the data in one or more files or filegroups. The files in a SQL Server database can be backed up and restored individually. Also, you can specify a whole filegroup instead of specifying each constituent file individually. Note that if any file in a filegroup is offline (for example, because the file is being restored), the whole filegroup is offline and cannot be backed up. A file backup can serve as the differential base for differential file backups. File backups can increase the speed of recovery by letting you restore only damaged files, without restoring the rest of the database.</p>
<pre><strong><span style="color: #008000;">--Backup the files in the TechYaz_FG secondary filegroup.</span></strong>
 <strong> <span style="color: #0000ff;">BACKUP DATABASE TechYaz</span></strong>
 <strong><span style="color: #0000ff;"> FILE = 'TechYaz_Data',</span></strong>
 <strong><span style="color: #0000ff;"> FILE = 'Techyaz_Data1'</span></strong>
 <strong><span style="color: #0000ff;"> TO DISK = 'D:\Backups\TechYaz_25Aug2017_filebck.bak';</span></strong>
 <strong><span style="color: #0000ff;"> GO</span></strong>

<strong><span style="color: #008000;">--Back up the files in TechYaz_FG filegroup.</span></strong>
 <strong> <span style="color: #0000ff;">BACKUP DATABASE Sales</span></strong>
 <strong><span style="color: #0000ff;"> FILEGROUP = 'TechYaz_FG'</span></strong>
 <strong><span style="color: #0000ff;"> TO DISK = 'D:\Backups\TechYaz_25Aug2017_filegrp.bak';</span></strong>
 <strong><span style="color: #0000ff;"> Go</span></strong></pre>
<pre><strong><span style="color: #008000;">--Back up the files in TechYaz_FG filegroup.</span></strong>
 <strong> <span style="color: #0000ff;">BACKUP DATABASE Sales</span></strong>
 <strong><span style="color: #0000ff;"> FILEGROUP = 'TechYaz_FG'</span></strong>
 <strong><span style="color: #0000ff;"> TO DISK = 'D:\Backups\TechYaz_25Aug2017_filegrp.drn';</span></strong>
 <strong><span style="color: #0000ff;"> With DIFFERENTIAL</span></strong></pre>
<h3><span style="color: #000080;">Partial Backup</span></h3>
<p>A partial backup resembles a full database backup, but a partial backup does not contain all the filegroups. A partial backup includes all the read/write files in a database: the primary filegroup and any read/write secondary filegroups, and also any specified read-only files or filegroups. A Partial backup can be issued for either a Full or Differential backup. This can not be used for Transaction Log backups. Partial backups are not supported by SQL Server Management Studio or the Maintenance Plan Wizard.</p>
<pre><strong><span style="color: #008000;">--Backup Partial Full Backup</span></strong>
 <strong> <span style="color: #0000ff;">BACKUP DATABASE TechYaz READ_WRITE_FILEGROUPS</span></strong>
 <strong><span style="color: #0000ff;"> TO DISK = 'D:\Backups\TechYaz_25Aug2017_Partial.bak';</span></strong>
 <strong><span style="color: #0000ff;"> GO</span></strong>

<strong><span style="color: #008000;">--Backup Partial Differential Backup</span></strong>
 <strong> <span style="color: #0000ff;">BACKUP DATABASE TechYaz READ_WRITE_FILEGROUPS</span></strong>
 <strong><span style="color: #0000ff;"> TO DISK = 'D:\Backups\TechYaz_25Aug2017_DFNPartial.drn';</span></strong>
 <strong><span style="color: #0000ff;"> WITH DIFFERENTIAL</span></strong>
 <strong><span style="color: #0000ff;"> GO</span></strong></pre>
<p>I hope you like this article. Please follow us on our <a href="https://www.facebook.com/Techyaz/">facebook page</a> and on <a href="https://twitter.com/Tech_yaz">Twitter </a>handle to get latest updates.</p>
<p>The post <a href="https://techyaz.com/sql-server/backup-recovery/understanding-sql-server-backups/">Understanding SQL Server Backups</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/backup-recovery/understanding-sql-server-backups/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Understanding SQL Server Recovery Model</title>
		<link>https://techyaz.com/sql-server/backup-recovery/understanding-sql-server-recovery-model/</link>
					<comments>https://techyaz.com/sql-server/backup-recovery/understanding-sql-server-recovery-model/#comments</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Sat, 09 Sep 2017 12:00:07 +0000</pubDate>
				<category><![CDATA[Backup & Recovery]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Administration]]></category>
		<category><![CDATA[Backups]]></category>
		<category><![CDATA[bulk-logged]]></category>
		<category><![CDATA[checkpoints]]></category>
		<category><![CDATA[full]]></category>
		<category><![CDATA[log_files]]></category>
		<category><![CDATA[recovery]]></category>
		<category><![CDATA[Recovery Model]]></category>
		<category><![CDATA[simple]]></category>
		<category><![CDATA[transaction log]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=829</guid>

					<description><![CDATA[<p>A Recovery Model is a database property that designed to control transaction log maintenance. SQL Server Recovery Model does not define how transactions will be logged but they define how transaction logs will be managed in the transaction log file.&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/backup-recovery/understanding-sql-server-recovery-model/">Understanding SQL Server Recovery Model</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>A Recovery Model is a database property that designed to control transaction log maintenance. SQL Server Recovery Model does not define how transactions will be logged but they define how transaction logs will be managed in the <a href="https://techyaz.com/sql-server/understanding-transaction-log-architecture/" target="_blank" rel="noopener">transaction log file</a>. There are three types of recovery models in SQL Server:</p>
<ul>
<li>Simple</li>
<li>Full</li>
<li>Bulk-Logged</li>
</ul>
<h3><span style="color: #000080;">Simple Recovery Model</span></h3>
<p>Simple recovery model is used for databases that are not critical or the database is static and data is not changing. We generally use SIMPLE model for lower life cycle databases. Main reason for this is point in time recovery is not possible because transaction log backup is not allowed in this recovery model and database engine automatically clears transactional logs during checkpoint operation. If you want to <a href="https://techyaz.com/sql-server/checkpoint/" target="_blank" rel="noopener">understand checkpoint operation</a>, you should read attached article.</p>
<p>A common <strong>myth</strong> is that when a database is configured in Simple recovery model then transactions will not be logged in transaction log files. This is not true and <strong>every transaction is logged to the transaction log file</strong>. Only difference is that, when that <strong>transactions will complete</strong> and data is written to disk all <strong>logs will flush</strong> and be available to log another transaction in same log file. This way you can also deal with the space issue.</p>
<p>Log Shipping, <a href="https://techyaz.com/sql-server/alwayson-availability-group/" target="_blank" rel="noopener">AlwaysOn Availability group</a> and <a href="https://techyaz.com/sql-server/point-in-time-recovery/" target="_blank" rel="noopener">Point-in-Time Restores</a> are not possible in this SIMPLE model because transaction log backups are not allowed in this recovery model. We can recover any database that are running in SIMPLE model till last full or differential backups only. Run below command if you want to view or change the recovery model of the database.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span class="kwrd" style="color: blue;"><span style="color: #008000;">--Check the Recovery Model of the database YourDB_Name
<span style="color: #0000ff;">SELECT name, recovery_model_desc  
   FROM sys.databases  
      WHERE name = 'YOURDB_NAME' ;  
GO</span>
--Change Recovery Model to SIMPLE</span>
ALTER DATABASE DBNAME SET RECOVERY SIMPLE
GO
</span></strong></pre>
<h3><span style="color: #000080;">Full Recovery Model</span></h3>
<p><a href="https://techyaz.com/sql-server/point-in-time-recovery/" target="_blank" rel="noopener">Point in time recovery</a> is possible in full recovery model that is why we use this recovery model for all production and critical databases. Every transactions that are logged in this recovery model can be backed up. Transaction log backup will capture all the logs and clears all the inactive portions of the transaction log file.  You can handle your <a href="https://techyaz.com/sql-server/get-total-virtual-log-files/" target="_blank" rel="noopener">log file space management</a> by scheduling frequent transaction log backups.</p>
<p>You can also clear the transaction logs from log files by switching the recovery model from Full to Simple but this is never recommended for any production database. If you change the SQL Server recovery model from Full to Simple, logs will be flushed from log file without getting captured into transaction log backup. That will break the log sequence and you will end up losing the point in time recovery for your database. That is why switching recovery model from full to simple is not recommended for production database.</p>
<p>As transaction log backups are allowed in this recovery model so you can recover your database till point in time and there will be no data loss in this recovery model.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span class="kwrd" style="color: blue;"><span style="color: #008000;">--Change SQL Server Recovery Model to FULL</span>
ALTER DATABASE DBNAME SET RECOVERY FULL
GO
</span></strong></pre>
<h3><span style="color: #000080;">Bulk-Logged Recovery Model</span></h3>
<p>Bulk-logged recovery model works similar to Full recovery model except few exceptions during bulk operations. You can use this recovery model if you have to run BULK operations on your database. Bulk-logged recovery model minimally logged such bulk operations to reduce the transaction log space.</p>
<p>Point in time recovery is not possible if you have performed any bulk operation during that time due to the nature of minimally logged operation. If you haven&#8217;t performed any bulk operation then point in time recovery can be achieved. Microsoft does not suggest to run any database in bulk-logged recovery model if you don&#8217;t have to run any bulk operations.</p>
<p>Best practice is that you change a database recovery model to the bulk-logged immediately before running bulk operations and restore it back to the full recovery model when those operations complete. Also you should run a log backup before switching to bulk-logged recovery model and again take the log backup once you return back to full recovery model post completing bulk operation. Your backup strategy remains the same and it will not break your log sequence. Run below command to change the recovery model to bulk-logged.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span class="kwrd" style="color: blue;"><span style="color: #008000;">--Change Recovery Model to BULK-Logged</span>
ALTER DATABASE DBNAME SET RECOVERY FULL
GO
</span></strong></pre>
<h3><span style="color: #000080;">Change Recovery Model using GUI</span></h3>
<ol>
<li>Connect to SQL Server Instance. in Object Explorer, click the server name to expand the server tree.</li>
<li>Expand <strong>Databases</strong> folder and click on the database for which either you want to change the recovery model of view the recovery model.</li>
<li>Right-click on that database, and then click <strong>Properties</strong>, which opens the <strong>Database Properties</strong> dialog box.</li>
<li>In the <strong>Select a page</strong> pane, click <strong>Options</strong>.</li>
<li>The current recovery model is displayed in the <strong>Recovery model</strong> list box.</li>
<li>Optionally, to change the recovery model select a different model list. The choices are <strong>Full</strong>, <strong>Bulk-logged</strong>, or <strong>Simple</strong>.</li>
<li>Click <strong>OK</strong>.</li>
</ol>
<p>I hope you like this article. Please follow us on our <a href="https://www.facebook.com/Techyaz/">facebook page</a> and on <a href="https://twitter.com/Tech_yaz">Twitter </a>handle to get latest updates.</p>
<p>The post <a href="https://techyaz.com/sql-server/backup-recovery/understanding-sql-server-recovery-model/">Understanding SQL Server Recovery Model</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/backup-recovery/understanding-sql-server-recovery-model/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>How to Recover or Repair Suspect Database in SQL Server</title>
		<link>https://techyaz.com/sql-server/backup-recovery/how-to-recover-or-repair-a-suspect-database-in-sql-server/</link>
					<comments>https://techyaz.com/sql-server/backup-recovery/how-to-recover-or-repair-a-suspect-database-in-sql-server/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Wed, 02 Mar 2011 06:46:00 +0000</pubDate>
				<category><![CDATA[Backup & Recovery]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Administration]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[HowTO]]></category>
		<category><![CDATA[suspect database]]></category>
		<guid isPermaLink="false"></guid>

					<description><![CDATA[<p>Suspect database in SQL Server is not very common issue but there are times we face it because of various reasons. Such reasons can cause a database to go in suspect mode and become inaccessible for end users. There are&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/backup-recovery/how-to-recover-or-repair-a-suspect-database-in-sql-server/">How to Recover or Repair Suspect Database in SQL Server</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Suspect database in SQL Server is not very common issue but there are times we face it because of various reasons. Such reasons can cause a database to go in suspect mode and become inaccessible for end users. There are some steps we can follow to fix this issue like manually bringing database online, checking any databases files are missing or not etc. If nothing will work then we will run DBCC CHECKDB command to fix suspect database issue. You should be cautious while using this command as you might have data loss while running DBCC CHECKDB command with REPAIR_ALLOW_DATA_LOSS. I will explain these steps in this article.</p>
<h2>Reason for Database Suspect Mode in SQL Server</h2>
<p>Here, i will explain the list of possible reasons which can cause your database to move into SUSPECT mode. Below is the list of such reasons.</p>
<ul>
<li>Improper shutdown of the database or database server.</li>
<li>Hardware Failure.</li>
<li>Corruption in database file/s.</li>
<li>There is not enough space available for the SQL Server to recover the database during startup.</li>
<li>Inaccessible database files or Insufficient memory.</li>
<li>Missing any Database files</li>
<li>Sudden Power Outage</li>
<li>System Failure</li>
<li>Database files drive letters mistyped/changed during any maintenance work.</li>
</ul>
<p>If your database is showing in SUSPECT mode, you should check any reason from above list for this issue. Next, i will show you how to recover or repair suspect database in SQL Server.</p>
<h2>SQL Server Suspect Database Fix</h2>
<p>This section will explain how to bring database ONLINE from SUSPECT mode in SQL Server. To troubleshoot and repair suspect database,  first you need to analyze your database server. You need to check whether all database files are in same location where they should be. if not, get the reason why files have been moved to another drive and by whom. You can move the files to previous location or you can change/update the location of these database files in SQL Server catalogue view using ALTER command. Additionally, you can also check whether all databases files are safe and none of these database files are missing from their respective location.</p>
<p><em><strong><span style="color: #800000;">Related Articles:</span></strong></em></p>
<ul>
<li><strong><a href="https://techyaz.com/sql-server/how-to-get-when-your-db-was-restored-last-time/" target="_blank" rel="noopener">How to get Last Restore Time of your database?</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/understanding-sql-server-data-files-pages-extents/" target="_blank" rel="noopener">Understanding Data Files, Pages &amp; Extents</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/understanding-sql-server-recovery-model/" target="_blank" rel="noopener">Understanding SQL Server Recovery Models</a></strong></li>
</ul>
<p>Sometimes, database files drive letters got changed as human error during some maintenance work. If this is the case, don&#8217;t do anything on the database server and ask your windows or platform team to revert the drive letter name where your database files have been placed to the correct name. You can also do this change if you are authorized to do this.</p>
<p>Once you have checked the drive letters and there is no change in it then you can try to run below SQL statement to bring your database online.</p>
<pre><span style="color: #008000;"><strong>--Change DBNAME with your database name that is showing in suspect mode.</strong></span>
<strong><span style="color: #0000ff;">Alter database DBNAME SET ONLINE.
</span></strong></pre>
<p>Sometimes databases come online by running above Alter statement if there is no serious issue with the database.</p>
<p>Get information about power outage or any hardware or system failure. If this is the case then first we need to address these issues and then we can recover the databases. If your database is HA enabled and you have system failure then you can use standby database for your business transactions.</p>
<p>If nothing works and all above steps are failed to bring suspect database ONLINE then we will run DBCC CHECKDB T-SQL statement to get all database corruption errors due to which database went in suspect mode:</p>
<pre><span style="color: #0000ff;"><strong>DBCC CHECKDB ([DBNAME]) WITH NO_INFOMSGS, ALL_ERRORMSGS</strong></span></pre>
<p>Above command will thoroughly check database integrity and return issues and corruption errors in the output section. You can read and review output of above DBCC CHECKDB command to understand the corruption or integrity issue in database.</p>
<p>Once you have enough information about errors then your next step would be Repair this suspected database. If error is showing data files missing then check your data file drive connectivity from storage side if it&#8217;s missing then you don’t need to do anything just contact someone from storage or one who manages storage in your environment and ask them to check data file drive is healthy or not. If storage is also ok then we will repair our database using below t-sql codes:</p>
<pre><strong><span style="color: #0000ff;">ALTER DATABASE [DBNAME] SET EMERGENCY
go
ALTER DATABASE [DBNAME] SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
go
DBCC CHECKDB ([DBNAME], REPAIR_ALLOW_DATA_LOSS) WITH NO_INFOMSGS, ALL_ERRORMSGS;
go
ALTER DATABASE [DBNAME] SET Multi_USER;
</span></strong></pre>
<p>Put your db name in place of [DBNAME] in above script. Above alter statement will change database into emergency mode and then repair the corruption present on data pages.</p>
<p>If your database does not come online post running above Alter statement then only option left is to restore your database with the copy of latest backups.</p>
<p><strong><span style="color: #ff0000;">Note:</span> </strong>REPAIR_ALLOW_DATA_LOSS is a one way operation i.e. once the database is repaired all the actions performed by these queries can’t be undone. There is no way to go back to the previous state of the database. So as a precautionary step you should take backup of your database before executing above mentioned queries.</p>
<p>I hope you like this article. Please drop your questions and feedbacks in below comment section. You can also follow our <strong><a href="https://www.facebook.com/Techyaz/">Facebook</a></strong> page and <strong><a href="https://twitter.com/Tech_yaz">Twitter</a></strong> handle to get latest updates.</p>
<p>The post <a href="https://techyaz.com/sql-server/backup-recovery/how-to-recover-or-repair-a-suspect-database-in-sql-server/">How to Recover or Repair Suspect Database in SQL Server</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/backup-recovery/how-to-recover-or-repair-a-suspect-database-in-sql-server/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Understanding Point in Time Recovery in SQL Server</title>
		<link>https://techyaz.com/sql-server/backup-recovery/point-in-time-recovery/</link>
					<comments>https://techyaz.com/sql-server/backup-recovery/point-in-time-recovery/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Sun, 12 Sep 2010 06:02:00 +0000</pubDate>
				<category><![CDATA[Backup & Recovery]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Backups]]></category>
		<category><![CDATA[recovery]]></category>
		<category><![CDATA[restore]]></category>
		<guid isPermaLink="false">http://techyaz.com/big-data/point-in-time-recovery/</guid>

					<description><![CDATA[<p>Point In Time recovery is a process to recover or restore your database till the point it was lost. Sometimes detrimental command will probably be issued against one of your databases and you will need to recover the lost data.&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/backup-recovery/point-in-time-recovery/">Understanding Point in Time Recovery in SQL Server</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Point In Time recovery is a process to recover or restore your database till the point it was lost. Sometimes detrimental command will probably be issued against one of your databases and you will need to recover the lost data. There are several actions that you might be able to take to recover the lost data, but what option makes the most sense. One option that SQL Server offers is the ability to do point in time restores of your data in order to restore your database back to the point right before that detrimental command was issued.</p>
<p><em><strong><span style="color: #800000;">Related Articles:</span></strong></em></p>
<ul>
<li><strong><a href="https://techyaz.com/sql-server/understanding-sql-server-recovery-model/" target="_blank" rel="noopener">Understanding SQL Server Recovery Models</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/understanding-sql-server-backups/" target="_blank" rel="noopener">Read Different Types of SQL Server Backups</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/backup-recovery/sql-server-backup-recovery-interview-questions-answers/" target="_blank" rel="noopener">SQL Server Backup and Recovery Interview Questions</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/how-to-get-when-your-db-was-restored-last-time/" target="_blank" rel="noopener">How to get Last Restore Time of your database?</a></strong></li>
</ul>
<h3><span style="color: #000080;">Point in Time Restore</span></h3>
<p>1-This topic is relevant only for databases that are using <strong><a href="https://techyaz.com/sql-server/understanding-sql-server-recovery-model/" target="_blank" rel="noopener">full or bulk-logged recovery mode</a></strong>. Under the bulk-logged recovery model, if a log backup contains bulk-logged changes, point-in-time recovery is not possible to a point within that backup. The database must be recovered to the end of the transaction log backup.<br />
2-Restore the last full database backup and, if any, the last differential database backup without recovering the database (RESTORE DATABASE database_name FROM backup_device <strong>WITH NORECOVERY</strong>).<br />
3-Apply each transaction log backup in the same sequence in which they were created, specifying the time at which you intend to stop restoring log (RESTORE DATABASE database_name FROM WITH STOPAT=time, RECOVERY).<br />
4-The basic syntax is:</p>
<div class="codediv">
<pre class="prettyprint lang-sql"><span style="color: #0000ff;"><strong>RESTORE LOG database_name FROM WITH STOPAT =time, RECOVERY
</strong></span></pre>
</div>
<h5><span style="color: #000080;">T-SQL Code:</span></h5>
<div class="codediv">
<pre class="prettyprint lang-sql"><span style="color: #333399;"><strong><span style="color: #008000;">-- Restore the full database backup.</span>
RESTORE DATABASE AdventureWorks
FROM disk='backup file location'
WITH NORECOVERY;
GO
<span style="color: #008000;">-- Restore the required Log backup with STOPAT keyword.</span>
RESTORE LOG AdventureWorks
FROM disk='backup file location'
WITH RECOVERY, STOPAT = 'Apr 15, 2005 12:00 AM';
GO
</strong></span></pre>
</div>
<p>I hope you like this article. Please follow our <a href="https://www.facebook.com/Techyaz/">facebook</a> page and <a href="https://twitter.com/Tech_yaz">Twitter </a>handle to get latest updates.</p>
<p>The post <a href="https://techyaz.com/sql-server/backup-recovery/point-in-time-recovery/">Understanding Point in Time Recovery in SQL Server</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/backup-recovery/point-in-time-recovery/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
