Here's what I have understood from your question :
Your Full backup taken yesterday failed to restore on your TestingDB. Hence, you took a latest full backup and that got restored successfully. After this you are trying to restore a differential backup from yesterday.
This will not work. Here's the reason it will not work. Everytime a backup happens let it be FULL\DIFF or LOG. it generates an LSN, this LSN is a chain and unique number which matches with each other and are compared at the time of restore.
If you have taken latest FULL backup then now you should take the latest diff backup and try to restore it on TestingDB and you should not get any errors you received earlier. Also, while restoring you can check the LSN of Full and Diff backup files by using RESTOREHEADERONLY command which reads the headers of your .bak file and gives you the information about First and Previous LSN.
I hope this helps in solve your problem.
That won't work. As soon as you recover the database after restore, that begins a new timeline for the database.
If this is an on-going process, one possible solution is to get the team generating the backups to take a differential every day which will have fairly low impact on effort and system load. This is in addition to what they currently have. However, it will require some careful management of the files to ensure you have the right sequence of full backup, differential and tlogs. The benefit is, you will not have more than the 20 tlog files to apply if you ever need to restore the database to the latest version. You also don't lose existing PITR based on the 15-20 tlog backups taken daily (I'm assuming there is some PITR requirement given the number of log backups).
If you want to further reduce the number of log files to apply, you can increase the number of differential backups per day but I'd wager the added complexity in managing the files far outweighs the benefits. If you script all your tasks (sounds like you are), execution and scrutinizing for issues is fairly easy to do. If you're using the SSMS GUI, well, you really shouldn't.
** To make it clear, this assumes you already reset the backup chain with a full database backup at some interval. Having just a single full DB backup and only taking differentials and tlog backups from there on is not a viable solution. In most situations, the differential will eventually grow to a large size, possibly bigger than the base (full DB) backup if you have lots of write activities. An example of a basic backup cycle might look like:
- Full DB backup - every Sunday 2am
- Differential DB backup - every day
- 8pm Transaction log backup - every 15minutes
This cycle has potential data loss of up to 15 minutes if there are no other protections (e.g. AlwaysOn) in place.
If this is just a 1-time thing, i.e. you won't get any more tlog backups then you could reduce your recovery time when the goal is to get to the latest point-in-time available. Just restore the DB, differential and apply all the logs. Once done, take a backup of that and keep it along with all the other backup files you have. This buys you rapid recovery when you need to get to the latest version available since you only need to do a single DB restore. However, don't delete all the other backup files in case you need to restore to a specific point-in-time other than the most recent.
Best Answer
Because, as the Restore and Recovery Overview doc says:
The recovery process is responsible for bringing a consistent database back online, and the database doesn't have to be moved or restored from a backup for that action to happen (a crashed database would trigger a recovery before coming back online). After a backup is restored a recovery should happen to guarantee a consistent database. Restore and recovery walk close together.
If you have a SQL Server in your desktop (or a lab environment that you can restart), follow these steps:
Recovery:
Management > SQL Server Logs
;Restore:
Create a folder
C:\BackupSQL
on the computer SQL Server is installed;Connect to SQL Server and run the following:
Check the current log to see messages like:
As you can see, you issued a
RESTORE
and SQL Server executed the restore and a recovery process to guarantee a consistent database in the end of your request.Consistency:
Imagine a situation where you owe me U$$ 500.00 and you're going to transfer the money from your bank account to mine:
Connected to SQL Server run these commands: USE Lab;
As you can see, each of us has U$$ 1000.00;
Run the commands to transfer the money:
Open another tab on Management Studio and execute this query:
You can see the U$$ 500.00 was reduced from your account, but it hasn't been added to mine yet;
Now let's cause a database crash by abruptly ending SQL Server service:
start menu > run > taskmgr
. Look for the process called something like SQL Server Windows NT and end it;That transaction was interrupted in the middle and it won't be finished when SQL Server service is available again. You're in big trouble if it stays like that because U$$ 500.00 was taken from your account and you still owe me U$$ 500.00 and I can prove it with my bank statement. To avoid inconsistencies like that SQL Server executes the recovery process before bringing a database online.
To start SQL Server service again and check our bank accounts
start menu > run > services.msc
, look for SQL Server service and start it;Query the table again and feel relieved that the recovery process did it's job and put the database in a consistent state where that half transaction was undone:
You can check SQL Server Log again and see that process, but once again, no backup was restored, only a recovery process occurred.