map the drive of the other server to your database server
10.11.233.20\d$
once mapped ,run folowing command in sqlserver query prompt:
EXEC xp_cmdshell 'net use D: \\ip adress of remote server\d$ /user:username password'
eg.
EXEC xp_cmdshell 'net use D: \\10.11.233.20\d$ /user:Administrator atpl@123'
now you can schedule the backup using following command
DECLARE @MyFileName varchar(50)
SELECT @MyFileName = (select 'D:\SQLBACKUP\m2wservices_tr_'+replace((replace((replace((convert(varchar(50),GetDate(),20)),'-','')),':','')),' ','') +'.bak')
BACKUP DATABASE [m2wservices_tr] TO DISK=@MyFileName WITH NOFORMAT, NOINIT, SKIP, REWIND, NOUNLOAD, STATS = 10
to delete the entry for a drive
EXEC XP_CMDSHELL 'net use D: /delete'
No comments:
Post a Comment