Article ID: 286280 - Last Review: February 22, 2007 - Revision: 4.3 Description of the effect to database recovery after you add or remove database filesThis article was previously published under Q286280 On This PageSUMMARY
Adding database files between transaction log dumps in SQL Server 7.0 renders transaction log dumps created after the file addition unusable.
If you are trying to recover a database by using a full backup and a sequence of transaction log backups, a transaction log backup created after the addition or deletion of a database file cannot be used in the recovery process. An attempt to restore the first transaction log backup created after the addition of a file fails with the following error message:
Server: Msg 3155, Level 16, State 1, Line 1 The RESTORE operation cannot proceed because one or more files have been added or dropped from the database since the backup set was created. Server: Msg 3013, Level 16, State 1, Line 1 Backup or restore operation terminating abnormally. MORE INFORMATION
You can see an extension of the preceding problem in a Log Shipping setup. When you set up log shipping between two SQL Server 7.0 servers, the transaction log dumps are continuously being transferred and restored on the standby server. If, for any reason, a log file is added to the production database, the transaction log backups cannot be restored on the standby server without resynchronizing the log shipping pair.
For example, you might add a database file because of a lack of disk space on a particular drive. After you add a log file, log shipping cannot continue with the transaction log restores. Subsequent transaction log restores on the standby server fail with the error message stated in the "Summary" section. With SQL Server 2000 or SQL Server 2005, you can use a WITH MOVE command while restoring the transaction log backup that was created after the addition of the database file. The restore operation in SQL Server 2000 or in SQL Server 2005 can handle the addition of database files. For example, you can restore the first transaction log backup that is created after adding a database file by using this code: The sections that follow provide a sequence of steps that describe the behavior in SQL Server 7.0 and the improvements in SQL Server 2000 and in SQL Server 2005. SQL Server 7.0Consider a setup where a SQL Server 7.0 database is used in production and the database is being backed up continuously. When trying to restore from the backups, you must restore the last full backup (by using WITH NORECOVERY) followed by n-1 transaction log backups (by using WITH NORECOVEYR) and the last transaction log backup (by using WITH RECOVERY).The following steps describe a sequence leading to the addition of a database file between transaction log dumps on the production database and the resulting errors that occur when you use the backups to perform a restore are described. NOTE: The following steps were performed on a database in use.
To avoid the preceding errors, create a full backup after you add or delete one or more database files, which starts a new backup sequence. If the backup sequence created previously is the only recovery option available, restoring tran_log1.trn by using the WITH RECOVERY option recovers a database to the state just before the database files were added or removed. SQL Server 2000 and SQL Server 2005With SQL Server 2000 and SQL Server 2005, the addition or deletion of files is handled seamlessly without the need to start a new backup sequence. After adding a file to the database in the middle of a transaction log backup sequence, the next transaction log backup should be applied manually by using the WITH MOVE option.Consider a scenario similar to the one used for the preceding SQL Server 7.0 example. After a file is added to the production database by using:
Processed 1 pages for database 'northwind', file 'Northwind_log' on file 1. Server: Msg 5123, Level 16, State 1, Line 1 CREATE FILE encountered operating system error 3(The system cannot find the path specified.) while attempting to open or create the physical file 'E:\Program Files\Microsoft SQL Server\MSSQL\DATA\nwnd_d2.ndf'. Server: Msg 5183, Level 16, State 1, Line 1 File 'northwind_data2' cannot be created. Use WITH MOVE to specify a usable physical file name. Server: Msg 3013, Level 16, State 1, Line 1 RESTORE LOG is terminating abnormally. To work around this 5123 error message, follow these instructions:
SQL Server 2000 Log Shipping ScenarioIn a SQL Server 2000 Log Shipping setup, if a NDF/LDF file is added to the Primary database participating in Log Shipping, the same drive configuration should exist on all secondary servers that participate in Log Shipping with this Primary server, so that the transaction log backup can be restored successfully. If same drive/path do not exist on the secondary server(s), the LOAD job fails and you receive the following error message:
[Microsoft SQL-DMO (ODBC SQLState: 42000)] Error 5105: [Microsoft][ODBC SQL Server Driver][SQL Server]Device activation error. The physical file name 'C:\Program Files\Microsoft SQL Server\MSSQL$SQL2K1\data\northwnd_data2.NDF' may be incorrect.
[Microsoft][ODBC SQL Server Driver][SQL Server]File 'northwnd_data2' cannot be created. Use WITH MOVE to specify a usable physical file name.
[Microsoft][ODBC SQL Server
For example, if northwind_tlog_200101270220.trn is the first transaction log backup created after the addition of a file northwnd_data2 for database Northwind, run the following command to correct the failing load job: If the load_all column for the log shipping pair in the log_shipping_plan_databases table is set to 0, check the last_loaded_file column in the same table and set it to the transaction log backup that was loaded manually. In the preceding example the file is northwind_tlog_200101270219.trn. If load_all column option is set to 1, you can safely let the load job execute at its scheduled intervals. REFERENCESFor additional information, click the article number below to view the article in the Microsoft Knowledge Base:281122
(http://support.microsoft.com/kb/281122/EN-US/
)
INF: Restore File and Filegroup Backups in SQL Server
APPLIES TO
| Article Translations
|

Back to the top
