Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Backup

Status
Not open for further replies.

jawan

MIS
Apr 22, 2003
153
US
I have 2 servers lets say Server 'A' and Server 'B'
I want to make backup from Server 'A' and want to save on'B'
Is it possible...? how can i do it....?
What are the steps....?

Thanks
 
Hello,

Here is the SQL that I use in a job to backup my databases.

USE [CrMaster]

DECLARE @File varchar(100)
DECLARE @DeleteFile varchar(100)
DECLARE @Date datetime
DECLARE @DeleteDate datetime

SET @Date = GETDATE()
SET @DeleteDate = GetDate() - 4

SET @File = 'D:\MSSQL7\BACKUP\CrMaster_db_'
+ CAST (DATEPART(yyyy, @Date)AS varchar)
+ RIGHT('0' + CAST (DATEPART(mm, @Date) AS varchar), 2)
+ RIGHT('0' + CAST (DATEPART(dd, @Date) AS varchar), 2)
+ RIGHT('0' + CAST (DATEPART(hh, @Date) AS varchar), 2)
+ RIGHT('0' + CAST (DATEPART(mi, @Date) AS varchar), 2)
+ '.bak'

BACKUP DATABASE [CrMaster] TO DISK = @File

-- Delete old backup files
SET @DeleteFile = 'Del D:\MSSQL7\BACKUP\CrMaster_db_'
+ CAST (DATEPART(yyyy, @DeleteDate)AS varchar)
+ RIGHT('0' + CAST (DATEPART(mm, @DeleteDate) AS varchar), 2)
+ RIGHT('0' + CAST (DATEPART(dd, @DeleteDate) AS varchar), 2)
+ '*.bak'

Use Master
EXEC xp_cmdshell @DeleteFile, no_output


In each section SET @File and SET @DeleteFile you can set the path to any other server, as long as the user running the script has authority to the other drive.

Hope this helps,
Carla

Documentation: A Shaft of light into a Coded world
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top