Download presentation
Presentation is loading. Please wait.
1
From Basic to Something More
SQL Backup 102 From Basic to Something More
2
Thanks You
3
How I am I work for Virginia state as SQL DBA
I work 18+ year for IT and with SQL since SQL 7 I love computer, database and some computer game
4
Agenda Why database. Backup/Restore from user interface Backup Plan.
Backup from T-SQL - Parameters. Other database technique to help backup.
5
Why database IT DO ITS TASK BETTER then flat file. Store the data
INSERT, UPDATE and DELETE Return stored data SELECT High Availability Protect data BACKUP / RESTORE, Disaster Recovery Security: user, permission, encryption, SSL Performance Index, Index View, Statistic
6
Backup from User Interface
7
Restore from User Interface
8
Restore from User Interface
9
Backup / Restore Demo
10
Backup Plan – Backup Type
Full Database Backup Captures current state of the data at the time when backup is finished. Differential Database Backup Captures only the final state of data that has been changed since the last full backup. Transaction Log Backup Captures every change of the data that has been changed since last log backup. Tail Log Backup Similar to transaction log but perform on broken server from last transaction log to break time if possible with nonrecovery or continue_after_error option.
11
Backup Plan – Restore Type
With Recovery Database will be available for user after recovery. Recovery does roll forward after rollback. With Norecovery Database will be available for additional log recovery, but not for user. Recovery does NOT roll forward after rollback. With Standby (Warm Standby) Database will be available for additional log recovery and read-only for user, but recovery will create additional file for standby.
12
Sample Backup Plan Full Backup: every Sunday 8 PM.
Differential Backup: everyday at 8 PM except Sunday. Transaction Log Backup: everyday from 8 AM to 6 PM for each 2 hours.
13
Sample Backup Plan - Recovery
Failure on Wed at 1pm. Restore Full from Sun. Restore Differential from Tue. Restore Transaction Log from Wed (8am, 10am, 12pm). Restore Tail Log from 12pm to 1pm. With norecovery/no_truncate or continue_after_error
14
Backup Plan from User Interface
15
Backup Plan from User Interface
16
Backup from T-SQL - Backup Parameters
BACKUP { DATABASE | LOG} <database_name> TO <backup_device> [, <bd>] WITH differential copy_only, mirror to { compression | no_compression} description = ‘text’ | name = <backup_set_name> stats [ = %] buffercount = <val>, maxtransfersize = <val>, blocksize= <val> expire_date=<date>, retaildate=<days> { noinit | init }, { noskip | skip }, { noformat | format } encryption algorithm = {AES_128|AES_192|AES_256|TRIPLE_DES_3KEY} , <encryptor_options>) { noinit | init } append | overwrite { noskip | skip } check expiration date noformat = preserves existing media header and backup sets
17
Backup from T-SQL - Restore Parameters
RESTORE [DATABASE | LOG ] <database_name> FROM <backup_device> [, <bd>] WITH { recovery | norecovery | standby = <standby_file_name>} move <logical_filename> to <physical_filename> log only: { stopat = <datetime> | {stopmark | stopmark} = <lsn:lsn#|after <datetime> > } buffercount = <val>, maxtransfersize = <val> restart file = <file_id> Device can be DISK, TAPE, URL
18
Backup from T-SQL - Other Usable Parameters
RESTORE FILELISTONLY FROM <backup_device> RESTORE HEADERONLY FROM <backup_device> RESTORE VERIFYONLY FROM <backup_device> VERIFYONLY can lead to false positive (false good backup). It only check the backup file is readable, it does not attempt to verify the structure of the backup file. The best way to know the state of backup is restore the database with the backup file. VERIFYONLY does not attempt to verify the structure of the data in the backup file.
19
Demos Backup and Restore database from T-SQL.
Create backup plan with SQL Maintenance Plans. Restore filelistonly, headeronly and verifyonly.
20
Other Techniques Attach / detack database Import / Export
sp_detach_database <dbname> ] Sp_attach_database <dbname> ], = <fname> ] Import / Export ssms: db task Import / Export Data Dacpac: backup database structure and data (?) It is a aip file with extensile dacpac than contain xml files. ssms: db tasks Extract Data-tier application. Command line, powershell, Visual Studio and Red Gate SQL Compare.
21
Other Techniques Log Shipping Process that synchronize transaction log backup and its restore to a secondary database. Replication Process that replicate data at table level. Types: transactional, snapshot and merge (bidirectional)
22
Demos 2 Attach / Detach. Create dacpac file and see the content.
Import / Export. Log Shipping.
23
Questions?
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.