
Signature
Greg Moore
SQL Server DBA Consulting Remote and Onsite available!
Email: sql (at) greenms.com http://www.greenms.com/sqlserver.html
Hi greg,
That's pretty much what I'm after, I created a share folder & it backusp ok
but when it tries to restore it comes up with a device offline error:
Below is the sql for it: ( I removed the .bak extension off the finlesname
but didn't seem to make a differnce)
ALTER PROC MyBackupLiveData
@Office NVARCHAR(4),
@SecmanDB NVARCHAR(20),
@ERPEDB NVARCHAR(20),
@ControlDB NVARCHAR(20),
@CompanyDB NVARCHAR(20)
AS
DECLARE @FilePath NVARCHAR(60)
DECLARE @FullPath NVARCHAR(60)
DECLARE @DatePart CHAR(8)
DECLARE @DBName NVARCHAR(30)
-- CREATE DATE TO APPEND TO BACKUP NAME
SET@DatePart = '_' + CONVERT(NVARCHAR, DATEPART(yyyy,GETDATE()))+
CONVERT(NVARCHAR, DATEPART(mm,GETDATE())) +
CONVERT(NVARCHAR, DATEPART(dd,GETDATE()))
-- TEMP TBL TO STORE DB NAMES TO BE BACKED UP
CREATE Table #Databases(DBName NVARCHAR(20))
-- INSERT ALL TABLES PASSED INTO PROC
INSERT #Databases VALUES (@SecmanDB)
INSERT #Databases VALUES (@ERPDB)
INSERT #Databases VALUES (@ControlDB)
INSERT #Databases VALUES (@CompanyDB)
-- CREATE CURSOR
DECLARE TablesCursor CURSOR
FOR
SELECT DBName FROM #Databases
OPEN TablesCursor
FETCH NEXT FROM TablesCursor INTO @DBName
WHILE @@FETCH_STATUS = 0
BEGIN
-- SET PATH & FILENAME OF BACKUP FILE
SET @FilePath = @Office + '\' + @DBName + @DatePart + '.bak'
SET @FullPath = 'C:\Backups\' + @FilePath
-- PERFORM BACKUP FROM LIVE SERVER
BACKUP DATABASE @DBName
TO DISK = @FullPath
-- PERFORM RESTORE TO TEST SERVER
SET @FullPath = '\\etestsql\Backups\' + @FilePath
RESTORE DATABASE @DBName
FROM DISK = @FullPath
FETCH NEXT FROM TablesCursor INTO @DBName
END
-- REMOVE ALL OBJECTS
CLOSE TablesCursor
DEALLOCATE TablesCursor
DROP TABLE #Databases
--- Thanks very much for your time on this
Ant
> > Hi,
> > Is it possible to specify a server in a backup script & likewise specify a
[quoted text clipped - 28 lines]
> when it's done with its backup fires off a job ON the other server to do a
> restore.
Greg D. Moore (Strider) - 03 Mar 2008 02:36 GMT
> Hi greg,
>
> That's pretty much what I'm after, I created a share folder & it backusp
> ok
> but when it tries to restore it comes up with a device offline error:
Make sure the box doing the restore has access to \\etestsql\Backups\.
Remember, this needs to be in the context that the SQL Server engine runs
in.
> Below is the sql for it: ( I removed the .bak extension off the finlesname
> but didn't seem to make a differnce)
[quoted text clipped - 104 lines]
>> a
>> restore.

Signature
Greg Moore
SQL Server DBA Consulting Remote and Onsite available!
Email: sql (at) greenms.com http://www.greenms.com/sqlserver.html
Ant - 04 Mar 2008 06:17 GMT
Hi Greg,
Many thanks for your help. Your answer was in fact what helped me out here.
Much Appreciated
> > Hi Greg,
> >
[quoted text clipped - 114 lines]
> >> a
> >> restore.