Apologies if I haven't used the correct terminology, I am not a DBA, but right now, I am all that is here!
Situation is last week, a database server was misbehaving (it was about 6 years old). The hosting company built a new server, and moved all the current data across to the new server, which is running well.
However, somehow, the new server is missing 36 hours of data. The hosting company has provided us with a backup that contains this data, amongst other things.
As some of the tables have auto generated keys (type integer
) is there any way of restoring just a set of data from a date range back into my live database? I obviously can't just cut and paste, as all the integrity of the data will be lost.
Thoughts?
Windows Server and Microsoft SQL Server 2008.
Best Answer
Not directly, but here's a work-around
The way you do partial restores of individual tables or rows in SQL Server is to restore the backups to a different database name and then manually move your specific missing data from the restored database back to your production DB.
This involves a couple of steps depending on your environment. If the original database is named DB1 then you can do something like:
This will give you the logical and physical file names to insert into the next step:
You will need to adjust that for your specific environment, but basically there are two critical points to remember:
If you have Diff backup files, then do
And then for each log file backup:
and so on until you've restored all the log files.
Finally,
After that, you can then start manually copying data from the restored DB to the original production DB.
But before you copy data back into the Production DB, take a full backup of that DB. Just in case.
If you need to insert data into tables with identity (autonumber) columns, use
The above is a very generic script and won't work without some effort on your part, but it should get you started. The Identity_Insert statements allow you to insert into an Identity column. Just be sure to get your WHERE clause right, so you don't insert bad data.