Generate database backup

7

In my project, I have a database that has a lot of registry. So I wanted SQL Server to do a backup a day or a week. But I think the per day is better.

But how can I make this script to be scheduled in SQL Server and it does the scheduled backup, without needing anyone forcing it to do it?

The version I use for SQL Server is 2012.

    
asked by anonymous 27.11.2014 / 13:23

1 answer

8

If you just want a Transact-SQL script to do the backup , you can use something like:

USE SeuBanco;
GO
BACKUP DATABASE SeuBanco
TO DISK = 'Z:\SQLServerBackups\SeuBanco.Bak'
   WITH FORMAT,
      MEDIANAME = 'Z_SQLServerBackups',
      NAME = 'Backup Full do SeuBanco';
GO

The basic syntax is:

BACKUP DATABASE nomeDoBanco 
TO lugarOndeSeraGravado

See the syntax for creating here and if you want to generate differential backups from a full backup, you can use the DIFFERENTIAL .

But it is recommended that you schedule a job to automate this using SQL Server Agent .

Right-click Jobs and then New Job ...

>

OntheGeneraltab,inName,typethenameyoufindconvenientforyourjob.

OntheStepstab,clicktheNewbuttontocreatethestepsofyourjob.

Enter a name for the step, type backup , script and configure the schedule.

Formoredetails,takealookat here .

    
27.11.2014 / 14:35