I'm learning about SQL Server backup/restore options. Not in a class or anything, but because I've recently realized that the guy here before me set things up very inefficiently. For instance, full backups ran once a day, and transaction backups ran once an hour. All this was done through jobs, not maintenance plans. In researching how to improve the setup where I work, I've learned a lot, but also gotten stuck on a few points. I'm hoping for confirmation of what I think I know, and clarification for what I don't yet fully grasp. Thanks in advance!
As I understand it, a full backup is just that--a complete backup of every bit in the database files, including transaction logs, up to the time the backup began. A differential backup is the same thing, but only encompasses changes made since the last full or differential backup was performed. These generally run once a day or so, whereas full backups run once a week or so.
First question: how does the system know when that last backup took place? A flag in the database? Does it open and look in the backup destination file? Is it set internally whenever a backup runs and doesn't fail?
Transaction backups confuse me a bit. I know that this type backs up the transaction log from the last full/differential backup until the current moment, but then what's a "tail log"? I see it referenced in documentation, and as far as I know, it's just the transaction log from the time of the most recent backup until "now". If my db fails seven minutes after a backup, I'd have a seven-minute tail log to worry about, right?
Were I to restore my failed database, how exactly would I do it? Let's say it failed on Tuesday, at 3:41 PM. My full backup ran the previous Saturday at 2:00 AM, my differential ran the morning of the failure at 5:00 AM, and my transaction backup ran every fifteen minutes, so I have good data up to 3:30 that Tuesday. My backups all go to a local server for storage, call it \backups. Thus, my files are in \backups\sql\full, \backups\sql\differential, and \backups\sql\transaction_logs.
- Is the folder structure the best way to organize backups? Is there a better or more standard way, or does it not matter?
- Given all that, how do I restore my database? I've done full restores, but never the other two. I'm using SSMS on Server 2012.
- What if I were to use these backups to move my database to a new server? Would the restore process be identical?
- Any other suggestions on how I might change this setup to be better?
My guess at the second question is to first take the failed database offline, then restore the full backup like I've done in the past. I'd next do the restore again, but this time choose the file from the differential backup. Finally, I'd repeat, this time using the transaction backup to restore to 3:30. I'd lose eleven minutes of data, but I don't think I have a choice. Or could I start with the transaction backup and see if it restores correctly, whereas the 'full restore first' idea is best for moving the database?
Anything else I should know about automating backups for all our databases? Some are pretty large, and we need to make sure we have as solid a backup plan as possible. I'd greatly appreciate any input anyone has on all this.