SQLserver create database backup and restore database backup

One, create a database backup

1. Command execution

BACKUP DATABASE [aa] TO  
DISK = N'H:\aa.bak' 
WITH NOFORMAT, INIT,  NAME = N'aa-完整 数据库 备份', SKIP, NOREWIND, NOUNLOAD, COMPRESSION,  STATS = 10
GO

2. Window execution

2.1 Call up the window

Before starting, please create an empty database

Select the database to be backed up, right-click-Task-Backup
Insert picture description here

2.2 Basic configuration

Here are basically the default, of course, you can customize it as you wish. Generally speaking, you have more needs for disk location modification.
Insert picture description here

2.3 bak configuration

Select Options

You can add backup data to the original bak file, or you can create a new bak file to store data
Insert picture description here

2.4 Select the storage location of the disk

Add to--…

To add data to an existing bak file, select the file directly and confirm

To create a new bak file to store data, select the path and customize a file name

Insert picture description here

2.5 Click OK to start backup

After the configuration is complete, click directly to confirm to complete the backup. The location of the backup file can be queried according to the customized disk path
Insert picture description here

Second, restore the database backup

1. Command execution

RESTORE DATABASE [aa] FROM  
DISK = N'C:\aa.bak' 
WITH  FILE = 1,  MOVE N'tmp' TO N'F:\DATA\aa.ndf',  MOVE N'tmp_log' TO N'F:\DATA\aa.ldf',  NOUNLOAD,  REPLACE,  STATS = 10
GO

2. Window execution

2.1 Call up the window

Select the database you want to restore the backup, right click the mouse-task-restore-database
Insert picture description here

2.2 Basic configuration

Add——... Insert picture description here
Note: If you click Confirm at this time, an error will be reported
Insert picture description here

2.3 Option configuration

Insert picture description here

2.4 Click OK, the backup is complete

Insert picture description here

Summary: Although the process is simple, it still needs to be patiently explored, recorded in time, and consolidated

Guess you like

Origin blog.csdn.net/qq_36636312/article/details/111361396