SQL Server Scheduled Database Backup 2005

Let's perform a scheduled backup of a SQL Server Database 2005 if you do not have any centralized backup system. We must keep in mind that this system is not going to replace the backups that are constantly being generated, therefore we have to look at or look for a solution so that it does not increase too much and fill up the disk.

Lo primero es conectarnos a nuestro servidor de Bases de Datos por medio de SQL Server Management Studio.

Nos situamos en el Agente de SQL Server -> Trabajos -> Boton derecho (Nuevo Trabajo)

En General rellenamos el nombre del Trabajo.

En Pasos pinchamos en Nuevo.

Rellenamos el Nombre del Paso, seleccionamos la BBDD y en comando introducimos el Script sguiente que nos realizara la Copia de Seguiridad por fecha:

DECLARE @strDatabase nvarchar(50)
DECLARE @strFolder nvarchar(500)

SET @strDatabase = NNOMBRE_BBDD
SET @strFolder = NRUTA_DESTINO

DECLARE @tToday datetime
SET @tToday = GETDATE()

DECLARE @strBackupName nvarchar(100)
SET @strBackupName = @strDatabase + N’ ‘
+ STR(DATEPART(year, @tToday), 4, 0)
+ REPLACE(STR(DATEPART(month, @tToday), 2, 0), N’ ‘, N’0′)
+ REPLACE(STR(DATEPART(day, @tToday), 2, 0), N’ ‘, N’0′)
+ REPLACE(STR(DATEPART(hour, @tToday), 2, 0), N’ ‘, N’0′)
+ REPLACE(STR(DATEPART(minute, @tToday), 2, 0), N’ ‘, N’0′)

DECLARE @strBackupFile nvarchar(600)
SET @strBackupFile = @strFolder + N” + @strBackupName + N’.bak

BACKUP DATABASE @strDatabase
TO DISK = @strBackupFile
WITH
NOFORMAT,
INIT,
SKIP,
NAME = @strBackupName

En Programacion pinchamos en Nuevo.

Damos un Nombre, seleccionamos el tipo de programacion que queremos (diaria, weekly…), marcamos los dias que nos interesan y le damos una hora de actuacion.

Aceptamos todo y ya tenemos creada nueva backup programada.


Recommended Posts

Author

nheobug@bujarra.com
Autor del blog Bujarra.com Cualquier necesidad que tengas, Do not hesitate to contact me, I will try to help you whenever I can, Sharing is living ;) . Enjoy documents!!!