Tải bản đầy đủ (.pdf) (5 trang)

Brad’s Sure Guide to SQL Server Maintenance Plans- P33 docx

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (565.15 KB, 5 trang )

Chapter 12: Back Up Database (Full) Task
161
also that the full database backup job will be completed before people come to work in the
morning. As you can see, there are a lot of assumptions being made, and this is why I referred
above to this discussion as being dicey.
As discussed in Chapter 4, when you schedule jobs using the Maintenance Plan Wizard, you
have to take an initial guess as to when a job should run so that it doesn't interfere with other
jobs. Once you have tested your jobs, and also run them for a few days, you will get a better
feel for how good your assumptions were. If they were wrong, you will then have to change
the various scheduled jobs so that they "fit" better together. You will learn how to change a
Maintenance Plan schedule in Chapter 19, on the Maintenance Plan Designer.
Another thought may have occurred to you during this discussion: is it possible to schedule
the daily full backup job at a specified time Monday through Saturday, and then at a different
time on Sunday, so as not to interfere with the weekly Sunday maintenance jobs? Yes, it is,
but it is at this point that the Maintenance Plan Wizard falls short, as it does not allow you to
set multiple schedules for a single task within the same Maintenance Plan. The work-around
for this is to create multiple Maintenance Plans, each with their own independent schedules.
Another option is to use the Maintenance Plan Designer, which allows greater flexibility than
does the Wizard.
In other words, what I am saying is that, if you want to perform tasks that are not easily done
from within the Wizard, such as creating multiple schedules for the same task, then you
should probably consider using the Maintenance Plan Designer to create your Maintenance
Plans, or using T-SQL or PowerShell scripts instead.
Summary
Of all the maintenance tasks you perform, the most critical one is the Backup Database
(Full)task. Performing regular full backups is the only way you can guarantee that your data
is protected should the original database become unavailable. On the other hand, the Backup
Database (Full)task is not the only backup task you need to perform regularly. In the next
two chapters, we will take a look at two other backup-related tasks.
162
Chapter 13: Back Up Database


(Dierential) Task
As you can guess by its name, this task is designed to create differential backups, in other
words, to back up all changes in a database since the last full backup.
Performing differential backups is not a substitute for making regular transaction log
backups. If your databases are in the full recovery mode, transaction log backups must be
included in your overall backup strategy alongside full backups and any differential backups.
For reasons that will become clear as we progress through the chapter, I generally avoid
performing differential backups if I can, preferring to rely on a combination of full and
transaction log backups. Furthermore, if your database maintenance requirements do include
performing differential backups, then I recommend that you create your Maintenance Plans
using the Maintenance Plan Designer (see Chapter 16 onwards), rather than the Wizard.
An Overview of the Back Up Database
(Dierential) Task
Since differential backups only copy the data that has changed since the last full backup
(called the differential base), a differential backup is smaller than a full backup, so the nightly
backup process is faster. However, as each day of the week passes, the differential backup will
take longer to perform, as more and more data changes in the database.
When the Backup Database (Differential) task runs using its default settings, it executes
the following T-SQL code (assuming AdventureWorks is being backed up):
BACKUP DATABASE [AdventureWorks] TO DISK = N'C:\Program
Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\Backup\
AdventureWorks_backup_2009_08_19_154600_2850000.bak' WITH
DIFFERENTIAL, NOFORMAT, NOINIT, NAME = N'AdventureWorks_back
up_2009_08_19_154600_2830000', SKIP, REWIND, NOUNLOAD, STATS = 10
This BACKUP DATABASE command is virtually identical to the one we saw in the last chapter,
for the Backup Database (Full) task, the only real difference being the addition to the
command of the DIFFERENTIAL keyword.
Unfortunately, the name assigned to the differential backup file looks exactly like the name of
Chapter 13: Back Up Database (Differential) Task
163

a full backup (other than the date stamp), making it dicult to distinguish full backups from
differential backups. To keep track, take note of the time stamp for the differential base file
(last full backup) and then identify subsequent differential backup files from there.
When a Backup Database (Differential) task runs, it produces a text report similar to
the following:
Microsoft(R) Server Maintenance Utility (Unicode) Version
10.0.2531
Report was generated on "HAWAII."
Maintenance Plan: MaintenancePlan
Duration: 00:00:00
Status: Succeeded.
Details:
Back Up Database (Differential) (HAWAII)
Backup Database on Local server connection
Databases: AdventureWorks
Type: Differential
Append existing
Task start: 2009-08-19T15:54:39.
Task end: 2009-08-19T15:54:39.
Success
Command: BACKUP DATABASE [AdventureWorks] TO DISK = N''C:\
Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\
Backup\AdventureWorks_backup_2009_08_19_155439_1450000.bak'' WITH
DIFFERENTIAL , NOFORMAT, NOINIT, NAME = N''AdventureWorks_back
up_2009_08_19_155439_1450000'', SKIP, REWIND, NOUNLOAD, STATS =
10
GO
As you can see, the text report above is also virtually the same as the report for the Backup
Database (Full), other than the references to "differential." If more than one database were
having a differential backup, then you would see each of them in the report.

When and How Often to Perform
Dierential Backups
Personally, I avoid differential backups, preferring to perform daily full backups, plus periodic
transaction log backups. I find this process simpler and less confusing than combining full,
differential, and transaction log backups as part of my backup plan.
Chapter 13: Back Up Database (Differential) Task
164
Of course, there are reasons why you might want to incorporate differential backups in
your Maintenance Plan. The most common reason given to use differential backups is
when databases are very large, and taking a full backup each night is too time-consuming.
What some DBAs do in these cases is to take a full backup once a week, and take differential
backups for the remaining days of the week, while also incorporating transaction log backups.
This reduces the amount of time each day it takes to perform a backup. On the other hand,
as the week progresses, the differential backup time will get longer and longer, as data is
changed in the database, negating some of the time savings provided by using differential
backups. Only by experimenting will you know for sure if using differential backups is a good
solution for your particular environment.
Configuring the Back Up Database
(Dierential) Task
Let's examine the Define Back Up Database (Differential) Task screen from the
Maintenance Plan Wizard, shown in Figure 13.1.
The available options are the same as those seen and described for the Backup Database
(Full) task in the previous chapter, so I'll refer you there for the details and will keep the
explanation here short.
The Backup type option at the top of the screen is automatically filled in by the wizard, and
displays Differential.
Database Selection and Backup Component
If you decide to perform differential backups, you'll have to give the following question some
thought: do you want to perform differential backups on all the databases on your server, or
just some of them?

In the context of the Wizard, differential backups can quickly trample over our goal of
simplicity. Our aim throughout the book has been to apply each task to the same set of
databases. So ideally, in the content of our running example, we'd select to apply differential
backups to all user databases.
Chapter 13: Back Up Database (Differential) Task
165
Figure 13.1: Creating and scheduling a differential backup task is virtually identical to
taking a full backup.

×