Figure 12.7: Generally, the second option, selected by default, is the choice to make.A striped backup can, under certain conditions, speed up the backup process.. Create a backup file f
Trang 1Figure 12.7: Generally, the second option, selected by default, is the choice to make.
A striped backup can, under certain conditions, speed up the backup process However, like backup devices, this option is not used very often, because there are many better ways to boost backup performance that are faster, save disk space, and are easier to administer This better way, backup compression, we will discuss a little more in the pages ahead
As you have probably already guessed, I recommend that you don't use this option in your Maintenance Plan If, for some reason, you do need it, you may be better off using T-SQL or PowerShell scripts instead, as trying to use this option via the Maintenance Plan Wizard is tedious and not very flexible
Create a backup file for every database
This is the default option, and the one you should select It will automatically create a new backup file on disk for each database you selected in the Database(s) section of the screen Backup files will automatically be assigned the name of the database, along with the word
backup: and the date of the backup This means that you can easily identify which backup file
is which, and when it was taken This option has three of its own sub-options Let's look at them one at a time
Create a sub-directory for each database
If you select this option, a sub-directory will be created for each database you back up, and the associated backups will be stored there So, if you back up two databases, one called Sales and one called Marketing, then backups for the Sales database will be stored in a
Trang 2sub-sub-directories because I don't like to go through multiple levels of folders to view my backup files However, other DBAs like the organization provided by using this option The choice is yours
Folder
This defines the parent folder that will used to store all database backup files arising from execution of this task The choice of folder is a very important decision, and you should not automatically select the default folder to store your backups
Ideally, you will have a destination designated specifically for storing backups, on a locally attached drive, SAN, or NAS device Your backups should not be stored on the same drive locations as your "live" MDF and LDF files, otherwise you might experience I/O contention, when backups are made, that could affect the performance of your servers Use the browse button to select the backup location
Backing up over a network
You can also perform backups over the network using this option This is not my personal preference because, if you have a network problem while the backup is being made, the backup will fail, and the Maintenance Wizard doesn't provide a way to recover If you have to back up over the network, then you need to consider a third-party backup tool that is designed for network resilience; or to create your own T-SQL or PowerShell
script that can detect a failed backup and then restart it once the network is back up
and running.
Backup file extension
The default backup file extension is BAK and it should not be changed If you change it, you risk confusing yourself, and others, about which files are backups and which are not
Verify backup integrity
The next option is Verify backup integrity, as shown in Figure 12.8
Trang 3Figure 12.8: I strongly suggest that you always select this option.
When this option is selected, the RESTORE VERIFYONLY command will be run against the completed backup This command performs multiple checks on the backup to test that the backup is complete and readable While the command does not verify the structure of the data in the backup (that is what the Check Database Integrity task is for, see Chapter 5), it does a very good verification of the backup and, if it passes the verification, you can be fairly certain the backup is a good one
Don't rely on the Verify backup integrity option alone!
It is a very good test, but it is still not perfect The only way to verify that you have a
good backup is to perform a restore and see if you can read the data Ideally, you should randomly select backups on a regular basis, and perform a test restore on them to ensure that your backup and restore process is working as expected.
Next on the screen is the option Back up the tail of the log, and leave the database in the
restore state, which is grayed out This is normal, as this is a generic screen (and code) that
is used in other parts of Management Studio, and it is not applicable to the creation of a Maintenance Plan
Set backup compression
The Set backup compression option is only available if you have the Enterprise Edition of SQL Server 2008 It is not available with the Standard Edition of SQL Server 2008 or with any edition of SQL Server before 2008
Third-party backup compression
If you are running Standard Edition, or an older version of SQL Server, but would like the ability to compress your backups, you can You just need a third-party application, such as Red Gate's SQL Backup Purchasing a third-party backup application is a lot less expensive than purchasing the Enterprise Edition of SQL Server In addition, the backup compression included with the Enterprise Edition of SQL Server 2008 does not perform backup encryption, which means that your backups are not protected from prying eyes.
Trang 4Figure 12.9: The backup compression option offers three choices.
The first option, Use the default server setting, specifies that the backup file should be compressed using whatever is the default backup compression setting for your server This
is a sp_configure option where the compression default option server option is set to either 0, which is off, or 1, which is on By default, the server-side default backup compression setting is turned to 0
The second option, Compress backup, turns backup compression on and overrides the default setting for the compression default option server option This is the most likely option to choose, as it will guarantee that all the databases backed up by this Maintenance Plan will be compressed
The third option, Do not compress backup, tells the Maintenance Plan Wizard not to use backup compression If you have the compression default option server option set to 1, which means that backup compression is turned on, then selecting this option will override the server-wide setting, and the database backup will not be compressed This option is not really applicable to Maintenance Plans, and should not be used
Creating the Job Schedule
Finally, we arrive at the Schedule option, with which we are already familiar In our
running example in this book, most database maintenance is performed during the Sunday maintenance period For this task, though, we want to perform a full backup every day To create a daily schedule, there are two parts of the Job Schedule Properties screen to which
we need to pay particular attention
First, under Frequency, set the Occurs drop-down box to Daily, ensuring that a full backup will be made daily Second, under Daily frequency, select Occurs once at: and then enter the time of the day when the full backup is to be made In this example, the full backup will be made at 5 a.m All the other options on the screen can remain at their default values, and the final screen should look as shown in Figure 12.10
Trang 5Figure 12.10: The above schedule performs a full backup every day.
Why select 5 a.m to perform the full backups? This brings us to a particularly dicey issue Before I begin, I first want to repeat something I have said many times already in this book:
the purpose of using the Maintenance Plan Wizard is to keep database maintenance as simple
as possible With this philosophy in mind, I choose 5 a.m because it falls after the completion
of the last weekly job that is performed on Sunday
Unfortunately, neither the Maintenance Plan Wizard nor SSMS gives us an easy way to see our entire job schedule in a single view This means that you have to take extra care, when scheduling daily jobs, to make sure they don't interfere with weekly jobs
One of the last tasks we scheduled to run in the weekly maintenance window, on Sunday, was the Rebuild Index task, or the Reorganize Index task plus the Update Statistics task Whichever option is chosen to remove index fragmentation, we need to wait until that task
is complete before we schedule the daily Backup Database (Full) task, in order to prevent