Database backup and recovery, database backup and recovery

Source: Internet
Author: User
Tags sql server management sql server management studio

Database backup and recovery, database backup and recovery
Backup and recovery of databases 1. Open SQL Server Management Studio → Database: practice_20.gl is the database we need to back up.

2. Right-click the database to be backed up.
3. Click "delete" and then "add"
4. select the backup path and enter the name of the database you want to back up in the "file name" location (it is best to add a date after the name of the database you backed up to facilitate future search ), then, click "OK" to complete database backup.

Database restoration 1. Select the database you want to restore "Practice_JWGL", right-click the database, and choose task> restore> database.

2. In the displayed "Restore database" dialog box, select "source device", browse, add files, and select backup files.

3. Select the central source check box and click OK. (Backup options can be verified after backup)

Transact-SQL

-- Completely back up the database to the physical Backup device Backup DataBase Practice_JWGLTo disk = 'e: \ database \ practice_jwgl_20121.bak 'Go -- back up the database differential to the physical Backup device Backup DataBase Practice_JWGLTo disk = 'e: \ DataBase \ practice_jwgl_20121.bak 'With differentialGo -- verify whether the backup file on the physical backup device is valid Restore verifyonly from disk = 'e: \ DataBase \ pai'go -- restore database Practice_JWGLfrom practice_jwgl_20151121with file = 1, replacemove 'practice _ Your GL 'to 'e: \ DataBase \ Practice_JWGL.mdf ', move 'practice _ javasgl_log 'to 'e: \ DataBase \ practice_javasgl_log.ldf' go
With file = 1 to specify the 1st backup sets in the backup file.
-- Restore database practice_‑glfrom practice_‑gl_20151121with file = 2, recoverygo
The with norecovery parameter table indicates that the database is in the "restoring" State and does not perform any operations on the committed transactions. If no data is written, the default with recovery indicates rolling back uncommitted transactions.
The steps for restoring the database are: full database restoration-differential database restoration-tail log database restoration.
-- Open the master database use mastergo -- restore the complete database restore database practice_mongoglfrom practice_mongogl_20151121with file = 1, norecovery, replacego -- restore the differential database restore database practice_mongoglfrom mongofile = 2, restore log practice_javasglfrom practice_javasgl_20151121with file = 3, recoverygo

Principles of database backup and recovery

Generally, a file-type database is actually one or more files. The so-called backup takes these files into account on other media, and there may be a packaging process, or the process of burning to a DVD. This is the best way to back up and restore a file-type database, with the best efficiency and the simplest operation.

Some large databases manage their own buckets, such as partitions or disks, which are not recognized by the operating system. Such databases can also use tools such as GHOST to back up disks.

Many people may say that backup databases convert databases into SQL or text files. In fact, this is another concept called data migration, which aims to port the database data to other database management systems. Data migration is not suitable for routine database backup. Generally, key databases do not normally perform data migration. Generally, the database system provides dedicated data migration tools. Of course, these tools may be a series of SQL statements that can be compiled by yourself.

How to back up and restore a database

Attach your database file to the SQL server of the target computer.
For details, right-click "Database" in SQL Enterprise Manager (all tasks> attach database). In the displayed dialog box, select your database file and set the database name.
Note: The name of the attached database must be the same as that on your original machine. Otherwise, you must rewrite the database connection statement on your webpage.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.