On SQLServer database backup and restore

In life, most worried about is the database administrator database paralysis, resulting in loss of data, loss of any data will have very serious consequences, so we are in order to more effectively protect and recover data, you need to back up data.
In general, resulting in loss of data include several categories:
1, Error: abnormal program termination or logical errors
2, human error: Administrator misuse
3, a computer failure: the system crashes, hardware and software error caused
4, disk failure: read and write disk head crash, damage to the disk physical block
5, and stealing disaster: natural disasters, man-theft will cause
SQL server backup has the following three:
1, full backup: comprising a full backup of the entire database, the transaction log portion, backup of the database structure and file structure. It represents a complete database backup time. Is the basis of all backup types.

2, differential backup: Data refers to all changes since the last full backup of time to do a backup, the backup process can identify which part of the database is modified, and only do this part of the backup.

The advantage is speed differential backup, database backup time required for very little, but require prior differential backup has been performed a full backup.

3, the transaction log backup: records all changes to the database, when backing up the transaction log, consider the following factors:

After performing a full backup at least once in order to back up the transaction log;
in simple recovery model can not back up the transaction log;
if not consistent with its database backup, you can not restore the transaction log.
During execution of database transaction log backup, SQL server will do the following:
Back up the transaction log: from the last successful transaction log backup to the end of the current transaction log;
truncate the transaction log: to start the transaction log moving parts, discarding inactive section.
The transaction log backup is mainly T-SQL statement instead of the entire database structure, file structure or data.
There are also three recovery modes:
1, simple recovery mode: In simple recovery mode, not active log will be deleted, so I do not support transaction log backups. It is also because they do not support transaction log backups, the database can only be restored to a point in time backup, but can not restore the database to the point of failure or a specific point in time. Therefore, the simple recovery model only for small databases and database are not changed often.

2, the full recovery model: very important for the production database, such as banking, telecommunications systems, in the event of failure may be required to return to a moment in history, the event of failure, must ensure that data is not lost, ensure that data can be restored to failure status. In this way, you must use the full recovery model.

Full recovery model can prevent the loss of data in the event of a failure within the maximum range, which includes database backup and transaction log backups, and provide comprehensive protection, the impact of the database from media failures.

With support for transaction log backup, full recovery model database can be restored to any point in time a specified.

3, bulk-logged recovery model:
DBA in some cases need to be performed on the database data into a number of high-volume, update, or delete operation, such as a need to import millions of pieces of data, if in full recovery mode, these operations It will generate a lot of logging, resulting in low database performance. In this case, large capacity logged recovery model to improve performance.

Although the bulk-logged recovery model will be a complete record of other matters, but it is only the minimum record for bulk operations, as long as the log backup contains bulk operations, the database can only be restored to the end of the log backup can not be restored to a time transaction log backup point or a mark.
Backup device:
During backup, the general is to create a file to store backup data, the backup file is called backup device, as shown in the backup a backup device is created:
On SQLServer database backup and restore
Note: If you want to create an automatic backup, then SQL server agents must be enabled:
On SQLServer database backup and restore
create a backup plan:
Right-click the "maintenance plan", click "maintenance plan Wizard" to the Wizard to make a backup plan:
On SQLServer database backup and restore
On SQLServer database backup and restore
check the work to be performed:
On SQLServer database backup and restore
define the details:
On SQLServer database backup and restore
set up automatic cleanup to back up history:

Due to back up the database every day, over time, its backup files take up disk space is also growing, by modifying maintenance plan, can
On SQLServer database backup and restore
On SQLServer database backup and restore
all backup settings, it is best when the initial backup, conduct a comprehensive inspection to ensure the backup the foolproof.
After the backup is complete, view the backup file:
On SQLServer database backup and restore
On SQLServer database backup and restore
Here we delete database tables to simulate the database data loss
On SQLServer database backup and restore
On SQLServer database backup and restore
On SQLServer database backup and restore
On SQLServer database backup and restore

Guess you like

Origin blog.51cto.com/14227204/2417218