Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Database refresh in isolated environment Expand / Collapse
Author
Message
Posted Sunday, September 8, 2013 2:30 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Sunday, August 17, 2014 3:53 PM
Points: 1, Visits: 49
Dear experts,

I would greatly appreciate your help on my database "refresh" issue.

The scenario:

I have 12 databases on a QA server that were restored there from a Production server approx. 2 years ago.
Now QAs need to sync those 12 databases with databases on a Prod server; all account logins (and corresponding permissions) have to remain unchanged in QA environment - QAs only need to "refresh" databases so that data is as current as it is in Prod environment.

For security reasons there's no (and cannot be) connection between two servers (hence it is not possible to import data with append option), so I had to request DBAs on that Prod server to backup databases and to place backup files in a shared folder (already there).

My question is - what is the best way to "refresh" 12 databases in QA environment - is it to delete/drop old databases and restore them from backup files (then what would happen to the current QA server logins?) or is it to try to restore databases from backups without dropping 12 old databases and is this possible, would be data just appended to existing data and current logins stay unchanged ?

Thank you in advance for any input.
Post #1492583
Posted Monday, September 9, 2013 2:34 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Yesterday @ 12:45 PM
Points: 62, Visits: 408
The fastest way would be to script your QA environment Logins and permissions and then restore the Prod backups in QA and add your QA login back.

or


Since there is no connection between the Prod and QA servers, and you need just the Data (Tables) from prod to QA, try this approach :

1.Use Generate scripts wizard on the prod server to generate the schema and data scripts of the 12 Databases and move the scripts to QA server(Genarating the schema and data option will differ depending upon the version of Sql Server).

2.On the QA server, drop all the tables in those 12 Databases using the below :

use [database1]
go
EXEC sp_MSforeachtable @command1 = "DROP TABLE ?"
go
use [database2]
go
EXEC sp_MSforeachtable @command1 = "DROP TABLE ?"
go
.......

3. Directly execute the schema and table data script which was taken from Prod in the respective Databases by pasting them in SSMS, or if they are too large to open in the editor, use sqlcmd to load them :


sqlcmd -S Servername -d Databasename -i Scriptpath
(sqlcmd can take time depending upon the data in the tables)


This will ensure that only the tables are recreated along with latest data in the QA environment.



Post #1492690
Posted Monday, September 9, 2013 3:36 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: 2 days ago @ 3:38 AM
Points: 7,004, Visits: 8,448
of course if depends on the level of granularity of the grants for your current QA-accounts.

IMO scripting all grants may be the easiest approach.

Then, use restore db and run the scripts you generated in the previous step.


btw: When using SQLusers, we tend to use the same user names, but ensure sql passwords are different on every SQL instance.
After restore we can just use "ALTER USER" to resync. the accounts.
You will also need the generated scripts in this case, because of security being altered at QA side as part of the next release.
( but I hope that is included in your upgrade scripts )

Keep in mind when dropping objects, the grants for those objects that have been granted at object level, will also vanish.

Play it safe and always script it all before you start the next level and have your regular backups in plance.


You may even want to make some sqlagent jobs that will perform it all for you, or use Allens powershell variant to restore your production dbs to QA ( you'll need to modify the script a little bit if you want to fix it all )
Test Your SQL Server Backups with PowerShell




Johan


Don't drive faster than your guardian angel can fly ...
but keeping both feet on the ground won't get you anywhere

- How to post Performance Problems
- How to post data/code to get the best help


- How to prevent a sore throat after hours of presenting ppt ?


"press F1 for solution", "press shift+F1 for urgent solution"


Need a bit of Powershell? How about this

Who am I ? Sometimes this is me but most of the time this is me
Post #1492707
Posted Monday, September 9, 2013 4:11 AM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Today @ 4:56 AM
Points: 15,646, Visits: 28,028
I'll go one step farther than the others. In addition to scripting everything out and then running a restore, I'd get the scripts into some sort of source control so that you have the ability to manage this stuff over time, automate it further, etc.

You also might want to look at third party tools such as Red Gate SQL Compare. You can then compare structures between two databases, identify the differences and generate scripts from there.

DISCLAIMER: I work for Red Gate.


----------------------------------------------------
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood..." Theodore Roosevelt
The Scary DBA
Author of: SQL Server 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans

Product Evangelist for Red Gate Software
Post #1492721
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse