Link to home
Start Free TrialLog in
Avatar of jagwynn
jagwynn

asked on

How to copy online SQL Database for current data developmental database

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.  
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

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.
Avatar of jagwynn
jagwynn

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial