<?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>restore - Techyaz.com</title>
	<atom:link href="https://techyaz.com/tag/restore/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>Tips, Tutorials and How-to Topics</description>
	<lastBuildDate>Tue, 15 May 2018 15:26:01 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.1</generator>

<image>
	<url>https://techyaz.com/wp-content/uploads/2017/11/cropped-Site-icon-150x150.png</url>
	<title>restore - 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>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 fetchpriority="high" 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 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 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>
