Mike, I used this in 8.03.4xx
It’s not doing completely what you ask, but it’s 90%. Should get you a good start. This restored my dumped live database to TEST. All the “MOVE” stuff in the beginning is for full text indexing/catalogs if you have that enabled.
It updates the restored database to use the correct ports in sysagent. It also kills all system tasks that you would normally have running in LIVE. (you don’t want TEST doubly running any scheduled tasks (at least I didn’t).
You would need to update the paths and the dumped/backed-up database name, too. If you need help tweaking, email me directly.
Good luck. HTH
--
--
-- PROCEDURE TO UPDATE TEST DB
--
-- *** MAKE SURE TO CHANGE "FROM DISK" LOCATION EACH MONTH ***
RESTORE DATABASE [MfgTEST803]
FROM DISK = N'D:\SQLBackup\LIVE\mfgsys803_2011Jul17_.bak' -- **** CHANGE **** --
WITH FILE = 1,
MOVE N'mfgsys803' TO N'D:\SQLData\mfgtest803.mdf',
MOVE N'mfgsys803_log' TO N'D:\SQLLogs\Mfgtest803_log.LDF',
MOVE N'sysft_custxprt' TO N'd:\fulltextcatalogs\test\custxprt\custxprt',
MOVE N'sysft_fscalldt' TO N'd:\fulltextcatalogs\test\fscalldt\fscalldt',
MOVE N'sysft_fscontdt' TO N'd:\fulltextcatalogs\test\fscontdt\fscontdt',
MOVE N'sysft_glacct' TO N'd:\fulltextcatalogs\test\glacct\glacct',
MOVE N'sysft_glchart' TO N'd:\fulltextcatalogs\test\glchart\glchart',
MOVE N'sysft_invchead' TO N'd:\fulltextcatalogs\test\invchead\invchead',
MOVE N'sysft_jobasmbl' TO N'd:\fulltextcatalogs\test\jobasmbl\jobasmbl',
MOVE N'sysft_jobhead' TO N'd:\fulltextcatalogs\test\jobhead\jobhead',
MOVE N'sysft_langorg' TO N'd:\fulltextcatalogs\test\langorg\langorg',
MOVE N'sysft_langtran' TO N'd:\fulltextcatalogs\test\langtran\langtran',
MOVE N'sysft_orderdtl' TO N'd:\fulltextcatalogs\test\orderdtl\orderdtl',
MOVE N'sysft_orderhed' TO N'd:\fulltextcatalogs\test\orderhed\orderhed',
MOVE N'sysft_part' TO N'd:\fulltextcatalogs\test\part\part',
MOVE N'sysft_podetail' TO N'd:\fulltextcatalogs\test\podetail\podetail',
MOVE N'sysft_quotedtl' TO N'd:\fulltextcatalogs\test\quotedtl\quotedtl',
MOVE N'sysft_reqdetail' TO N'd:\fulltextcatalogs\test\reqdetail\reqdetail',
MOVE N'sysft_rfqitem' TO N'd:\fulltextcatalogs\test\rfqitem\rfqitem',
MOVE N'sysft_rcvdtl' TO N'd:\fulltextcatalogs\test\rcvdtl\rcvdtl',
MOVE N'sysft_shipdtl' TO N'd:\fulltextcatalogs\test\shipdtl\shipdtl',
MOVE N'sysft_ECORev' TO N'd:\fulltextcatalogs\test\ECORev\ECORev',
MOVE N'sysft_FAsset' TO N'd:\fulltextcatalogs\test\FAsset\FAsset',
MOVE N'sysft_CostPart' TO N'd:\fulltextcatalogs\test\CostPart\CostPart',
MOVE N'sysft_HDCase' TO N'd:\fulltextcatalogs\test\HDCase\HDCase',
MOVE N'sysft_ResourceCollection' TO N'd:\fulltextcatalogs\test\ResourceCollection\ResourceCollection',
MOVE N'sysft_WCGroup' TO N'd:\fulltextcatalogs\test\WCGroup\WCGroup',
MOVE N'sysft_xfileref' TO N'd:\fulltextcatalogs\test\xfileref\xfileref',
NOUNLOAD, REPLACE, STATS = 10
GO
USE MFGtest803;
UPDATE COMPANY SET NAME = '#-> TEST DATABASE ONLY <-#' WHERE COMPANY = 'MYCOMPANY' ; --UPDATE NAME HERE!!
UPDATE SYSAGENT
SET APPSERVERURL = 'AppServerDC://localhost:8323',
MFGSYSAPPSERVERURL = 'AppServerDC://localhost:8321'
WHERE AGENTID = 'SystemTaskAgent';
TRUNCATE TABLE sysagentsched;
TRUNCATE TABLE sysagenttask;
TRUNCATE TABLE sysagenttaskparam;
From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf Of Mike Tonoyan
Sent: Friday, October 25, 2013 5:31 PM
To: vantage@yahoogroups.com
Subject: [Vantage] SQL database restore to Pilot or Test
Has anyone successfully programmatically restored a SQL backup into Pilot or Test database? We backup our SQL database every two hours and would like to restore the last backup, which is at 6:00PM, into Pilot or Test database every night. To do this every night manually is almost impossible.
_________________________________________________________________________________ Notice: This email transmission may contain confidential information and is intended only for the person(s) named. Any use, copying or disclosure to/by any other person(s) is strictly prohibited. By accepting this information, recipients confirm that they understand and will comply with all applicable ITAR and EAR requirements. _________________________________________________________________________________