Possible restore issue with 7.3.0.383 to replace database
ChrisAVWood
Posts: 361
Hi,
I am running on W2K12 on SQL2012 SP1 and when I try to use a script that has worked before on W2K3R2 on SQL2005 to restore a database with replace it seems to want to place the database on the same drive as the original backup. I am trying to restore to a folder on our E:drive, where the existing database is currently, from a backup that backed up a database that resided on a D:drive.
Now I am forced to add the move parameters. Looks like this means the default has changed from 7.1.
Here is a snippet of my script
EXECUTE master..sqlbackup N'-SQL "RESTORE DATABASE [AHAH_DEVL] FROM DISK = ''G:\DBABackupsOnly\FULL_AHAH_PROD_20130320_030300_23895.sq6'' WITH RECOVERY, REPLACE"'
go
The AHAH_DEVL resides on the E:drive and the AHAH_PROD resides on the D:drive.
This would tend to make this version unusable for us.
Chris
I am running on W2K12 on SQL2012 SP1 and when I try to use a script that has worked before on W2K3R2 on SQL2005 to restore a database with replace it seems to want to place the database on the same drive as the original backup. I am trying to restore to a folder on our E:drive, where the existing database is currently, from a backup that backed up a database that resided on a D:drive.
Now I am forced to add the move parameters. Looks like this means the default has changed from 7.1.
Here is a snippet of my script
EXECUTE master..sqlbackup N'-SQL "RESTORE DATABASE [AHAH_DEVL] FROM DISK = ''G:\DBABackupsOnly\FULL_AHAH_PROD_20130320_030300_23895.sq6'' WITH RECOVERY, REPLACE"'
go
The AHAH_DEVL resides on the E:drive and the AHAH_PROD resides on the D:drive.
This would tend to make this version unusable for us.
Chris
English DBA living in CANADA
Comments
Chris
E.g. this fails because the logical names in the backup set do not match that of the 'db2' database:
This succeeds because we restored 'db2' from the 'db1' backup set, preserving the logical names:
This also works because the logical names of both databases match.
SQL Backup Consultant Developer
Associate, Yohz Software
Beyond compression - SQL Backup goodies under the hood, updated for version 8
Here is what I did.
I created the new database under E:\applctn\ahah\devl\database with 3 files, SYS/DATA_001 and LOG_001. This is in SQL2012 running on W2K12. I had a backup taken using SQLBackup 7.1 in SQL2005 on W2K3R2 of the prod database where it resides under \applctn\ahah\prod\database with the same 3 files, SYS/DATA_001 and LOG_001. The backup creates two files to speed the process up.
I copied the 2 backups files to the W2K12 server. When I tried to run the script it failed because it tried to restore to \applctn\ahah\prod\database. Once I put the moved statements in it worked fine and replaced the original databases I had created. I had this happen to another database under the same circumstances. This made me believe that maybe the restore from script had looked at the backup files for its location information rather than the master DB locations.
We do lots of restored from production backups to at and dev servers where the file locations differ from the original ones and the script works fine. It gets its location information from the master DB rather than the backup file itself.
Can you check this out please?
Thanks
Chris
In SQL Server 2005 and 2008, you could overwrite an existing database, and have the existing database's data files (whose logical names match those in the backup set) replaced by those in the backup set, using the REPLACE option.
In SQL Server 2012, this is no longer the case. SQL Server 2012 insists on placing the data files in their original location, unless the existing database was originally restored from a backup of the same database.
In your case, you would need to first restore the dev database from a backup of the production database, using the MOVE options. After that, subsequent restores can be performed without the need for the MOVE options.
If it's any consolation, SQL Backup 7.3 can help somewhat with the MOVE options. If all the data files and trx log files can be grouped in the same folders, you can use the MOVE DATAFILES/LOGFILES shortcut e.g.
There is also MOVE FILESTREAMS ... for filestreams, and MOVE FULLTEXTCATALOGS ... for full text catalogs.
SQL Backup Consultant Developer
Associate, Yohz Software
Beyond compression - SQL Backup goodies under the hood, updated for version 8
That is really interesting. I will certainly test out the MOVE DATAFILES and MOVE LOGFILES options.
I now need to ask this further question. We will be using AlwaysOn Availability Groups. The thinking is this currently. We have a database on say the dev server, in a different location than the prod backup. We take the dev database out of the availability group and then restore the prod backup to both server A with recovery and to server B with norecovery. Then put the databases back into the availability group.
Based on what you have said and I saw I need the MOVE statements this first time. Now this stays the same for a few days and we start taking backups, on the node that the availability group allows. Now we have to perform another restore from prod to dev. Will I still need the MOVE or will SQL2012 remember where the databases reside on dev and I can restore without the MOVE?
Thanks
Chris
From what I can tell, as long as the database you are trying to restore over, and the backup set you are using to restore from, have the same family GUID value, SQL Server will use the file locations of the database you are now overwriting.
I don't know how to find out the family GUID value of an active database, but if you back up that database, you can read this value using the RESTORE HEADERONLY command.
SQL Backup Consultant Developer
Associate, Yohz Software
Beyond compression - SQL Backup goodies under the hood, updated for version 8