Solved

How to copy online SQL Database for current data developmental database

Posted on 2008-06-22
3
283 Views
Last Modified: 2013-11-30
I have a Access 2003 FE with a MS SQL 2005 backend.  I need to be able to copy the backend database at night to be able to update the data in an developmental database that we use to test against.  The developmental database can be on the same or a different server.  I have tried to use the replication (snapshot) but it is read only, I need to be able to have read write capabilities.  
Currently I am taking the database offline at night and manually copying the file group to a different server and renaming it and then attaching/renaming it to the developmental database, then putting the production database back online.  
I know that there is a way to automate this process (Scripts, Maintenance plan) but I am not sure were to begin.  I have very limited knowledge of SQL as we just upsized from a Access backend.  
0
Comment
Question by:jagwynn
  • 2
3 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 21841693
just a plain BACKUP DATABASE <dbname> TO DISK ...  and a RESTORE DATABASE <copy_of_database> FROM DISK ... WITH REPLACE, MOVE ... will do it.
please check out the syntax, if you need help, just ask.

this way you don't need to take the db offline.
0
 
LVL 1

Author Comment

by:jagwynn
ID: 21842055
Thank you,  I assume that the commands are correct to backup and restore the files.  I will be able to test this out tonight and respond if it works correctly.  And again thanks for the help!

RESTORE DATABASE <DatabaseName>
FROM DISK='<SourceBackupFile>'
WITH Recovery, Replace,
MOVE '<LogicalDataFileName>' TO '<DestinationDataFileName>',
MOVE '<LogicalLogFileName>' TO '<DestinationLogFileName>'


And just so that I understand it correctly
RESTORE DATABASE <DatabaseName> - The test database
FROM DISK='<SourceBackupFile>'  The backup from production database
WITH Recovery, Replace,  - Drop database and then restore file
MOVE '<LogicalDataFileName>' TO '<DestinationDataFileName>', - Move Data file
MOVE '<LogicalLogFileName>' TO '<DestinationLogFileName>'  Move Log file
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 125 total points
ID: 21842062
>And just so that I understand it correctly
yes, understood correctly

note: the logical and physical file name associations in the prod database can be queried by the sysfiles (or sys.files) view in the relevant database
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question