Saturday 14 May 2011

SQL 2008 database Backup and Restore process

Method:
1.Full
2.Differential
3.Transaction Log
4.File and File group backup

Data critical situation level is high. We could use the backup pattern below:
Sun Mon Tue Web Thu Fri Sat
F D D D D D D
T T T T T T
F: weekly Sunday
D: daily Mon, Tue, Web, Thu, Fri, Sat
T: per office hour

Create a backup device
w/ management studio
Server object -> New backup device -> File -> input the name and the location of the backup file

w/ store procedure
use master
exec sp_addumpdevice 'disk', 'MYDATA', 'c:\backup\mydata.bak' //create
exec sp_dropdevice 'disk', 'c:\backup\mydata.bak' //delete
go

Create a backup task
w/ management studio
Server object -> backup database

Setting schedule backup
1.start the sql server agent
start -> all programs -> microsoft sql server 2008 -> configuration tools -> sql server configuration manager -> find 'sql server agent' service
-> start
-> properties -> start method -> automatic

2.start agent xps option
sp_configure 'show advanced options',

go
reconfigure
go
sp_configure 'Agent XPs', 1
go
reconfigure
go

3. create schedule task for automatic backup
w/ management studio
Manage -> Maintenance plan -> maintenance plan wizard -> next -> name 'weekly full', schedule 'change' -> setup the date you need to do the full backup -> choose backup method 'full' -> next -> choose the database you need to backup, check verify backup integrity -> finish.

w/ T-sql
backup database AdventureWorks
to mybackup
with stats = 20

with options
blocksize = if you need to burn the file on a CD, set to 2048, use with format
name = backup set name
description = set backup description
differential: do the differential only, if not set this parameter, full as default
format | no format: set if overwrite the existing backup
compression | no_compression: if need to compress the backup or not, not set as system default value
nounload | unload: set when backup is finished, need to unload the tape or not
restart: if there is a power failure when doing backup, set this option to restart the backup job
stats: sql server is 10% by default, view the backup process percentage frequency

No comments:

Post a Comment