<?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>Backups - Techyaz.com</title>
	<atom:link href="https://techyaz.com/tag/backups/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>Tips, Tutorials and How-to Topics</description>
	<lastBuildDate>Fri, 01 Jun 2018 12:29:12 +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>Backups - 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>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 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="(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>Understanding ASYNC_IO_COMPLETION Wait type in SQL Server</title>
		<link>https://techyaz.com/sql-server/async_io_completion-wait-type/</link>
					<comments>https://techyaz.com/sql-server/async_io_completion-wait-type/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Tue, 24 May 2011 09:54:00 +0000</pubDate>
				<category><![CDATA[Performance Tuning]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Wait Types]]></category>
		<category><![CDATA[Backups]]></category>
		<category><![CDATA[performance tuning]]></category>
		<category><![CDATA[Waittypes]]></category>
		<guid isPermaLink="false"></guid>

					<description><![CDATA[<p>Normally, ASYNC_IO_COMPLETION Wait type can be seen during backup and restore activities. Whenever you will see this wait type your backup/restore process will be in suspended state most of the time because the process is waiting to get IO resource&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/async_io_completion-wait-type/">Understanding ASYNC_IO_COMPLETION Wait type in SQL Server</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Normally, ASYNC_IO_COMPLETION <strong><a href="https://techyaz.com/sql-server/what-is-sql-server-wait-type-or-how-to-get-wait-type-info-in-sql-server/" target="_blank" rel="noopener">Wait type</a> </strong>can be seen during backup and restore activities. Whenever you will see this wait type your backup/restore process will be in suspended state most of the time because the process is waiting to get IO resource to proceed their operation and it will wait till certain time period then moved in suspended state. In that case your process will take more than its usual time to complete or most of the time it will hung or will showing in executing state for unknown time duration.</p>
<p><em><strong><span style="color: #800000;">Related Articles:</span></strong></em></p>
<ul>
<li><strong><a href="https://techyaz.com/sql-server/what-is-sql-server-wait-type-or-how-to-get-wait-type-info-in-sql-server/" target="_blank" rel="noopener">Understanding SQL Server Wait Types</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/resource_semaphore-wait-type/" target="_blank" rel="noopener">How to deal with Resource Semaphore Wait type?</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/backupbuffer-wait-type/" target="_blank" rel="noopener">What is BACKUPBUFFER Wait type?</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/reduce-wait-type-preemptive_os_writefilegather/" target="_blank" rel="noopener">How to Reduce SQL Server Wait type PREEMPTIVE_OS_WRITEFILEGATHER?</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/improve-sql-server-bulk-data-import-performance/" target="_blank" rel="noopener">How to Improve SQL Server Bulk Data Load Performance?</a></strong></li>
</ul>
<p>ASYNC_IO_COMPLETION wait type occurs when a task is waiting for asynchronous I/Os to finish.  This wait type is normally seen with few other wait types like <a href="https://techyaz.com/sql-server/backupbuffer-wait-type/" target="_blank" rel="noopener">BACKUPBUFFER</a>, BACKUPIO etc. This is clear indication of DISK IO issue. You can also get the Average disk queue length or current disk queue length value at the same time when you are getting this wait type. Compare both counters and if these counters have high value then you should look into your storage subsystem. Identify disk bottlenecks, by using Perfmon Counters, Profiler, sys.dm_io_virtual_file_stats and SHOWPLAN.</p>
<p>Any of the following will reduce this wait type occurrence:</p>
<ol>
<li>Add additional IO bandwidth.</li>
<li>Balancing IO across other drives. If you are running your backups on same drive in which you have placed your database files. Make sure to keep separate drive for data, log and backups.</li>
<li>Reducing IO with appropriate indexing. This can cause major performance issue if you don&#8217;t have proper indexes.</li>
<li>Check for bad query plans that are consuming most of resources.</li>
<li>Check memory pressure if your server has enough memory to run resource extensive operations.</li>
</ol>
<p>We can also correlate this wait type between Memory pressure and Disk IO subsystem issues.</p>
<p>If you like this tip, you can follow us on our <strong><a href="https://www.facebook.com/Techyaz/">facebook page</a></strong> and on <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/async_io_completion-wait-type/">Understanding ASYNC_IO_COMPLETION Wait type 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/async_io_completion-wait-type/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to fix BACKUPBUFFER Wait Types?</title>
		<link>https://techyaz.com/sql-server/wait-types/backupbuffer-wait-type/</link>
					<comments>https://techyaz.com/sql-server/wait-types/backupbuffer-wait-type/#comments</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Fri, 06 May 2011 20:01:00 +0000</pubDate>
				<category><![CDATA[Performance Tuning]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Wait Types]]></category>
		<category><![CDATA[Backups]]></category>
		<category><![CDATA[Waittypes]]></category>
		<guid isPermaLink="false">http://techyaz.com/sql-server/wait-types/backupbuffer-wait-type/</guid>

					<description><![CDATA[<p>Today I was working on an issue in which backup job was showing in executing state since last 2 days.Initially my observation was either it was hung in middle of its process or it was processing very slow. Later, i&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/wait-types/backupbuffer-wait-type/">How to fix BACKUPBUFFER Wait Types?</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div dir="ltr" style="text-align: left;"></div>
<div>
<div dir="ltr">
<div>Today I was working on an issue in which backup job was showing in executing state since last 2 days.Initially my observation was either it was hung in middle of its process or it was processing very slow. Later, i decided to see the <strong><a href="https://techyaz.com/sql-server/what-is-sql-server-wait-type-or-how-to-get-wait-type-info-in-sql-server/" target="_blank" rel="noopener">wait types</a></strong> for this process. When i was gathering this info, i saw the wait type backupbuffer for this transaction.</div>
<h3><span style="color: #333399;">What is BACKUPBUFFER Wait Type</span></h3>
<div>This wait type Occurs when a backup task is waiting for data, or is waiting for a buffer in which to store data. This type is not typical, except when a task is waiting for a tape mount. This wait stats will occur when you are taking the backup on the tape or any other extremely slow backup system.This wait type can be seen with one more wait type i.e. <a href="https://techyaz.com/sql-server/async_io_completion-wait-type/" target="_blank" rel="noopener"><strong>ASYNC_IO_COMPLETION</strong></a>.</div>
<div><img loading="lazy" decoding="async" src="http://www.assoc-amazon.com/e/ir?t=sql031-20&amp;l=btl&amp;camp=213689&amp;creative=392969&amp;o=1&amp;a=B001UHWHO4" alt="" width="1" height="1" border="0" /></div>
<div>These both wait types indicate that the issue is with storage/disk subsystem. Solution is to either ask your storage team to look in this or change your disk/storage subsystem and run your backup on a healthy and fast storage subsystem. There are other options as well where you should focus if your storage subsystem is ok. Below is the list of options you should look into to overcome from this wait type.</div>
<div>
<ul>
<li>Add additional IO bandwidth to accommodate the load.</li>
<li>Balancing IO across other drives. If you are running your backups on same drive in which you have placed your database files. Make sure to keep separate drive for data, log and backups.</li>
<li>Reducing Disk IO pressure with appropriate <strong><a href="https://techyaz.com/sql-server/understanding-sql-server-indexes/" target="_blank" rel="noopener">indexing</a></strong>. This can cause major performance issue if you don&#8217;t have proper indexes.</li>
<li>Check for bad query plans that are consuming most of resources.</li>
<li>Check memory pressure if your server has enough memory to run resource extensive operations.</li>
</ul>
</div>
</div>
<h5><em><span style="color: #800000;"><strong>Related Articles:</strong></span></em></h5>
<ul>
<li><strong><a href="https://techyaz.com/sql-server/what-is-sql-server-wait-type-or-how-to-get-wait-type-info-in-sql-server/" target="_blank" rel="noopener">Understanding SQL Server Wait Types</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/resource_semaphore-wait-type/" target="_blank" rel="noopener">What is Resource Semaphore Wait type?</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/improve-sql-server-bulk-data-import-performance/" target="_blank" rel="noopener">How to Improve Bulk Data Load Performance?</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/sql-server-dmvs/clear-wait-statistics-data-sql-server/" target="_blank" rel="noopener">Should We Clear Wait Stats Data from DMV sys.dm_os_wait_stats?</a></strong></li>
</ul>
<div>If you like this tip, you can follow us on our <strong><a href="https://www.facebook.com/Techyaz/">facebook page</a></strong> and on <strong><a href="https://twitter.com/Tech_yaz">Twitter</a></strong> handle to get latest updates.</div>
</div>
<p>The post <a href="https://techyaz.com/sql-server/wait-types/backupbuffer-wait-type/">How to fix BACKUPBUFFER Wait Types?</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/wait-types/backupbuffer-wait-type/feed/</wfw:commentRss>
			<slash:comments>1</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>
