Friday, June 11, 2021

SQL backup,restore and script in SQL- part 5

  In this blog we are going to understand SQL backup , restore and scripts.


SQL  Backup :
  • A copy of sql server data that can be used to restore and recover the data after a failure.
  • backup of a database can also be used to restore a copy the database to a new location.
  • The backup copies the data or log records from database to device such as disc.


There are three main types of backup:

1.Full backup:
  • Full backup stores a full copy of a specific database at the point in time that the backup completed.
  • It contains all the data in a specific database or set of filegroups. 
  • This backup copy of all data to a storage device, such as a disk or tape.
2.Differential backup :
  • a copy of all data changes from the last full backup to the current point in time
3.Log backup :
  • It is the backup of transaction logs that have all log records that are not backed up in previous log backup.

Steps for back up database :

1) Connect to database and expand database, select the database which we want to backup :

         

2) Select the backup type, By default, it is Full -:

                        

3) You can add new destination and add .bak extension :
                          

4) Click on "Ok" and the database backup completed :
               

5) You can check whether the backup is created successfully or not by going to destination folder :
            



SQL  Restore :

  • The restore is a process of restoring or recovering data from backup.

Steps for restoring database :

1) Click on database => Restore database :

   

2) Click on device and select backup device : 

                         

3) Give name for database  :

     

4) Now database is restored successfully :

                      

5) And refresh database to see restored database :

  

SQL  Scripts :

  • We can create or generate scripts for transferring database between instances.
  • SQL script is a set of SQL commands which are stored as a file in SQL scripts.

Steps for generating scripts :

1)  Click on database => Task => Generate scripts :

                  

2) After clicking next, choose entire database or specific object :

                 

3)  Click on save as script file and destination :

                     

4)  We can see the scripts are saved, now click on finish :

 

5)  Open the destination folder and verify the script is generated or not :

 

6) Click on script file, we can see the set of commands :

 



For more understanding watch below video :


      
Thank You!!!

No comments:

Post a Comment

Function in SQL -part 8

  In this blog we are going to understand  Sql function.   FUNCTION: A function is a database object in SQL Server. It accepts only input pa...