viernes, 27 de abril de 2012

Restore database from UNC

This T-SQL, allows you to add a Backup device, from remote directory (Don't forgett to give permissions to source backup folder).

First of all, add de remote backup as Device

use master
exec sp_addumpdevice 'disk','RemoteBackupDevice','\\yourRemotePath\backup.bak'
go


Then restore de database from the Device created.

restore database yourdatabasename from [RemoteBackupDevice] with file=1,
move N'DATA_FILE_NAME' to N'c:\Data\DATA.mdf'
move N'DATA_LOG_NAME' TO N'C:\LogData\LOG.LDF'
, NOUNLOAD, STATS=5
go


or restore the backup databse without creatting a device

restore database yourdatabasename from disk ='\\yourRemotePath\backup.bak' with recovery;


go


That's all.

No hay comentarios:

Publicar un comentario