Backup and Restore Database in SQL Server

this time I will show how to backup database, first I have one database like this :

image

I want to backup database test, just right click on database test choose Task >> Backup.

image

you can choose another Destination folder by Clicking Remove and Add new Destination folder, the highlight text is destination folder of backup file.

image

Note : if you add another destination backup folder, don’t forget to put .bak at the end of filename like this :

image

after that Klik OK :

wait a few second and you will see information message like this :

image

RESTORE DATABASE

now I will delete database tes and try to restore it using backup file, first delete database tes and then create new empty database tes.

image 

as you can see, the database is empty. just right click on database tes and then choose Tasks > Restore > Database :

image

First Choose radio button From device, and point it to your backup destination folder, after that check Restore, and then choose Options properties.

image

then check Overwrite the existing database (WITH REPLACE), after that click OK

image

you will see this information message :

image

USE GENERATE SCRIPTS TO BACKUP DATABASE

this is the second alternative, you can use Generate script to backup database. I will Script database tes, just right click on database then choose Tasks > Generate Scripts, like this :

image

Klik Next :

image

You can Script entire database and all the objects or Select specific database object, in this case I choose Script entire database and all database object, then click Next :

image

You can choose the destination folder of Scripts by changing the File Name, after that click Advanced :

image

in this section, you can change Type of data to script, and I change it to Schema and data. after that click OK, then click Next until Finish

image

RESTORE DATABASE USING SCRIPTS

if you want to restore database using Scripts, just open Script in SQL Server and then execute it by pressing F5

image

success…

image