Backup and Restore
Backup and Restore
Backup and Restore
Simple – Committed transactions are removed from the log when the check point process occurs.
Bulk Logged – Committed transactions are only removed when the transaction log backup process occurs.
Full – Committed transactions are only removed when the transaction log backup process occurs.
Is the native SQL Server 2005 backups are in clear text or in encrypted?
With SQL Server 2008 is the introduction of natively encrypted database backups. Prior to SQL Server 2008 a third
party product was necessary to encrypt the database backups.
Backup:
1. sysadmin – fixed server role
2. db_owner – fixed database role
3. db_backupoperator – fixed database role
Restore:
1. Sysadmin – fixed server role
2. Dbcreator – fixed server role
3. db_owner – fixed database role
How can you be notified if a native SQL Server database backup or restore fails via the native tools?
Setup SQL Server Alerts to be sent to Operators on a failure condition. Include RAISERROR or TRY\CATCH logic in
your backup or restore code to alert on the failure.
Do all successful SQL Server backup entries can be prevented from writing to the SQL Server Error Log by a single
trace flag?
Yes – Just enable the trace flag 3226.
Explain how you could automate the backup and restore process?
1. Backups can be automated by using a cursor to loop through each of the databases and backup each one.
2. Restores can also be automated by looping over the files, reading from the system tables (backup or log
shipping) or reading from a table as a portion of a custom solution
What is the database that has the backup and restores system tables? What are the backup and restore system
tables? What do each of the tables do?
The MSDB database is the database with the backup and restores system tables. Here are the backup and restore
system tables and their purpose:
1. backupfile – contains one row for each data file or log file backed up
2. backupmediafamily – contains one row for each media family
3. backupmediaset – contains one row for each backup media set
4. backupset – contains one row for each backup set
5. restorefile – contains one row for each restored file
6. restorefilegroup – contains one row for each restored filegroup
7. restorehistory – contains one row for each restore operation
What are your recommendations to design a backup and recovery solution? Simply what is Backup Check list?
1. Recovery Model
2. Select Backup Types
3. Backup Schedule
4. Backup Process
5. Document
6. Backup to Disk
7. Archive to Tape
8. Backup to Different Drives
9. Secure Backup Files
10. Encrypt or Password Protect Backup Files
11. Compress Backup Files
12. How Much to Keep on Disk
13. Online Backups
14. Run Restore Verify only
15. Offsite Storage
Consider a scenario where you issue a full backup. Then issue some transaction log backups, next a differential
backup, followed by more transaction log backups, then another differential and finally some transaction log
backups. If the SQL Server crashes and if all the differential backups are bad, when is the latest point in time you
can successfully restore the database? Can you recover the database to the current point in time without using
any of the differential backups?
You can recover to the current point in time, as long as you have all the transaction log backups available and they
are all valid. Differential backups do not affect the transaction log backup chain.
What are the three basic phases for database recovery and in what order do they occur?
1. Analysis
2. Redo – rolls forward committed transactions
3. Undo – rolls back any incomplete transactions
What options/arguments can be specified in a BACKUP LOG statement to keep inactive log records from being
truncated?
SQL Server 2000: NO_TRUNCATE
SQL Server 2005/2008: NO_TRUNCATE, COPY_ONLY
What are all of the backup \Restore options and their associated value?
Backup Options:
1. Full – Online operation to backup all objects and data in a single database
2. Differential – Backup all extents with data changes since the last full backup
3. Transaction log – Backup all transaction in the database transaction log since the last transaction log backup
4. File – Backup of a single file to be included with the backup when a full backup is not possible due to the
overall database size
5. File group – Backup of a single file group to be included with the backup when a full backup is not possible
due to the overall database size
6. Cold backup – Offline file system backup of the databases
7. Partial Backup – When we want to perform read-write filegroups and want to exclude read-only filegroups
from backup. It will be useful for huge databases (Data warehousing)
8. Third party tools – A variety of third party tools are available to perform the operations above in addition to
enterprise management, advanced features, etc.
Restore Options:
1. Restore an entire database from a full database backup (a complete restore).
2. Restore part of a database (a partial restore).
3. Restore specific files or filegroups to a database (a file restore).
4. Restore specific pages to a database (a page restore).
5. Restore a transaction log onto a database (a transaction log restore).
6. Revert a database to the point in time
What are the issues you faced in backup and restore process?
Common Errors in Backup:
Error 3201 – when performing a backup to a network share
Solution: Where SQL Server disk access is concerned, everything depends on the rights of the SQL Server service
startup account. If you are unable to back up to a network share, check that the service startup account has write
rights to that share.
Error: Cannot open the backup device:
Sol: Either the specified location is missing or the service account under which the SQL Agent is running does not
have the permissions on that folder.
Consider a situation where I have to take a backup of one database of 60 GB. My hard drive lacked sufficient
space at that moment. I don’t find 64GB free on any drive. Fortunately, I have 3 different drives where I can hold
20 GB on each drive. How can you perform the backup to three different drives? How can you restore those files?
Is this really possible?
Yes it is possible. We can split the backup files into different places and the same can be restored.
All databases as available at the time of master db backup must be attached as everything is tracked in master
database.
If any databases are missing we can manually attach the mdf-ldfs.
Before rebuild:
1. Locate all recent backup of system databases
2. Make a note on mdf and ldf file locations, server configuration, Build /hotfix /sp applied
Rebuild:
1. Locate the Sql Server installation bits and run the command setup.exe fro command prompt by passing the
argument as “/ACTION=REBUILDDATABASE”
2. Review the summary.txt once the rebuild completes
Post Rebuild:
1. Restore all the system databases from existing backups
2. Move the system databases mdf/ldf files to the actual locations
On the Enterprise Edition of SQL Server 2005/2008, users are allowed access after REDO. So the point is REDO phase
is done first.
First we need to confirm that the master database is corrupted. We cannot restart SQL Server without the MASTER
database. By checking the error logs we can confirm that master database is corrupted.
To rebuild the master database we have to use setup.exe from command prompt. There is no much difference
between 2005 and 2008 except few command line switches.
Find the setup.exe file (C:\……………………….\100\Setup BootStrap\Release\setup.exe)
Run the below command from dos prompt
When setup has completed rebuilding the system databases, it will return to the command prompt with no
messages (It always first prints out the version). Examine the “Summary” log file (100\setup bootstrap\logs) to verify
it was completely successful.
setup\sql_engine_core_inst_msi\PFiles\SqlServr\MSSQL.X\MSSQL\Binn\Template
Once you have copied the file into the templates directory or repairing, re-run setup with the syntax I’ve described
above.
Standby / Read Only – Database is ready to use but database is in Read Only mode, user can connect to database but
they cannot change data inside database. A running database con not be changed to standby mode. Only a data in
no-recovery state can be moved to standby mode. This is an option that is specified while restoring a database or
transaction log.