Due to memory allowances, I need to backup my database to a separate remote server disk which has more space.
I want to do this using a scheduled job but it is not allowing me.
Is this even possible?
I've tried the below code, but get the error:
cannot open backup device
I'm wondering if I need to add access credentials to the server but am not sure how.
DECLARE @Location nvarchar(200)
DECLARE @Day int
SET @Day = DATEPART(dw, getdate())
Set @Location = '\\server2\E:\SqlBackups\'
Set @Location = @Location + 'Day'+ cast(@Day as nvarchar(1)) + '\'
Set @Location = @Location + 'COST.bak'
BACKUP DATABASE COST TO DISK = @Location WITH FORMAT, INIT, NAME =
N'COST-Full Database Backup', SKIP, NOREWIND, NOUNLOAD, COMPRESSION,
STATS = 10
declare @backupSetId as int
select @backupSetId = position from msdb..backupset where
database_name=N'COST' and backup_set_id=(select max(backup_set_id) from
msdb..backupset where database_name=N'COST' )
if @backupSetId is null begin raiserror(N'Verify failed. Backup
information for database ''COST'' not found.', 16, 1) end
RESTORE VERIFYONLY FROM DISK = @Location WITH FILE = @backupSetId,
NOUNLOAD, NOREWIND
GO
Check your UNC path it has to have "$" instead of ":"
Set @Location = '\\server2\E$\SqlBackups\'