Restore DB to a point in time SQL SERVER 2008 R2 - sql-server

I have a sql server 2008R2 DB with FULL recovery.
A full backup done nightly at 2am (overwriting the previous night's .bak file)
Every hour I have a Transnational backup .trn files
The last full backup was done today at 3am Sept 21.
Today I was asked to make a copy of the database to a previous time Sept 20th 12PM.
I know how to restore from an older last full backup (say Sept 20 3am) and then apply the .trn files to bring it up to a certain point in time (backup with norecovery then apply trns).
But is it possible to go backwards in time in my situation given that the only full backup I have was taken 3am Sept 21st? if not please tell me how I can change my backup strategy to be able to do it in the future if I run into this again.
thanks

Not knowing much about your organization needs
I would suggest taking a FULL Backup every night.
Differential Backup every one hour and then transaction backup every 10 to 5 mins or
whatever suits your organization needs best
and SET Expirydate for your backups for 5 to 7 days so that new backup will not overwrite the backups for so many days.
I think if you make a Backup strategy for your databases like this it will be helpful in future to go back in in time.
One more tip "A LESSON learnt the hard way" DO NOT FORGET to backup (master, model, msdb)
even once a week but make sure you have some sort of plan in place to backup these database.
I hope this reply will be helpful
Regards
Mo

Related

Is there a way to keep on restoring SQL database backups periodically, and meanwhile access the database from another application?

I'm periodically getting backups of an SQL database which I would like to restore in my machine. I'm able to do that with RESTORE fullDB WITH NORECOVERY; RESTORE differentialDB WITH RECOVERY;
However, I need to access the restored database in between, as the interval in which I'm getting the backups can be a few hours.
I tried restoring full backup WITH RECOVERY, but in that case I'm getting exception while restoring differential backup.
NB: It's not just one differential backup, it's real time backups taken every few hours. I'm using C# for executing the operations.
Any help is appreciated to solve the issue. Also, let me know if I'm barking at the wrong tree.
Instead of sending SQL database backups from client as .bak files, should I opt any other way to send the data?
Take a look at the STANDBY option for the RESTORE statement. From the docs:
Specifies a standby file that allows the recovery effects to be undone.
NB - differential backups are based on the last full backup taken. So let's say that you take full backups on Sunday, differential backups every other day of the week and you're restoring every day.
Sunday, you'd restore only the full backup, bringing it online for read by specifying STANDBY with the restore
Monday through Saturday, you'd restore the latest differential backup on top of what you've already restored, again using STANDBY
When Sunday rolls around again, you'd need to restore the new full backup.
That said, you mentioned that you're on SQL Express. The database size limit is 10 Gb. At that size, how long does the restore of the full backup take? Is it worth your time? And even there, it's really "how much time are you saving the robot?" because you've already (presumably) automated the restore.

Azure Recovery Services and SQL 2014 Managed Backups not playing well together

I started using Managed Backups on my SQL server. It has been working well for over a year. It seems to backup the dbs once a week, and take incrementals every 2 hours.
A month ago, we changed our VM backup solution to Azure Recovery Services. We started running it every night. When Azure Recovery Services runs in the evening, it looks like, from the Windows and SQL logs, it takes a backup of each database before it does a volume shadow copy. They are entered into the logs as TYPE=VIRTUAL_DEVICE: and a big GUID, and a new database lsn number is created. When this VM backup occurs my weekly Managed Backups are invalidated.
When I look in the msdb.dbo.smart_backup_files table where the SQL Managed Backup stores its records to keep track of its backups, I can see there are 2 fields that seem to be important. backup_type. When this equals 1 it is a full backup, and when it is a 2 it is a log. The next field is the backup_database_lsn. This field represents the full backup that the log can be applied to.
When the SQL Managed Backup runs its full backup once a week, a new lsn number is created, and every log file that is created afterwords, has a value in the backup_database_lsn number that points back to that lsn number of the full SQL Managed Backup for that week.
Now, when Azure Recovery Services runs nightly, a new full database lsn number is created from the TYPE=VIRTUAL_DEVICE line in the logs. When I look in the Managed Backup table (msdb.dbo.smart_backup_files) I can see that all then subsequent log files that used to point to the Managed Backup's full lsn number now point to the new lsn number for the VIRTUAL_DEVICE of the Recovery Services backup.
If I need to do a restore of the Managed Backups, I can only get the full backup and 1 days worth of logs. After that, all of the log files now point back to the Recovery Services VIRTUAL_DEVICE backup, which doesn't really exist.
I have looked for the VIRTUAL_DEVICE backup. When I open a database through Enterprise Manager, and click on Restore for a database, it pulls up the most recent full backup (in this case the Recovery Manager full backup), and its log files. If I click on the full backup entry, it believes the file is in the SQL Server backup folder with the name of the file being the GUID. That file does not exist, or it may exist in the night VM backup which I can't view in Azure Recovery Services. Either way, my weekly Managed Backup is invalidated for the rest of the week.
Does anyone know how to make these two work together? I would like to have a full VM backup in case something bad gets installed on the SQL Server and we need to do a full restore, and I'd like to have a weekly full backup with incremental log files in case we need to restore one database.
It sounds as if what you are looking for differential backups. Those would contain everything added to the database following the last full backup.
I.e. you take a full backup on Sunday evening, with a differential backup every day after. On Monday evening, your differential backup would contain everything added since the backup. On Tuesday, it'd contain everything it contained on Monday, as well as everything changed since then.
If you'd do the same using Transaction Log Backups, your Monday evening backup would actually be identical to the differential backup described above. However, the Tuesday version of the Transaction Log backup would only contain the changes from the time of the Monday transaction Log backup.
When it comes to restoring, this would mean that in order to restore to a point in time, you would have to restore the latest Full Backup (Sunday), followed by every transaction log backup since, in sequence (Monday, Tuesday, etc.).
Using Differential backups, though, you would restore the latest Full Backup (Sunday), followed by the latest Differential Backup (Tuesday, if you're restoring on Wednesday).

Automated Incremental backup sql only 5 days

This is my final hopes for expecting answer. Question is: How to do automated incremental backup in SQL Server only for 5 days? and how to schedule in task schedule tool. Please help me.
You might be confusing differential backups with incremental Backups.SQLServer doesn't have a concept of incremental backups..
You might get incremental effect (only backup what has been changed,from last backup) using Tlog*..Idea goes like this..
1.Take a Full Backup
2.Each day, by the end of day take Tlog backup
To Clarify,When you need to restore the backups /make database usable,you will need to restore Fullbackup ,followed by Tlog backups in order
*This is very Risky since ,it reduces your risk of restoring to a point in time
You can create a maintenance plan in SQL Server containing 2 parts:
A back up task for executing a backup every day (or every 5 days)
A clean up task for deleting all the backups older than 5 days.
Once created, you can plan it as a job in SQL Agent. Here's a great example about how to do it: Create a maintenance backup plan in SQL Server 2008 R2 using the wizard by Kyle Laffoon.

When doing a scheduled differential backup every 30 minutes, should the filename always change?

I have a client that has a puzzling thing running on the MS SQL 2008 server. They have a backup job running every 30 minutes doing a differential backup.
The filename of the backup is the same, so am I right in thinking that the SQL Server 2008 will continuously overwrite this file? Should the filename be change dynamically on each backup run? My understanding is that the differential backup is the changes that occurred since the last full backup. So overwriting the backup each time doesn't make sense to me.
Another puzzling thing is at end of day they have a FULL backup scheduled, and a differential backup at the same time. My thinking would be that this is also incorrect.
The full backup can occur at end of day, and then differential backups could occur after that, but for them to happen at the same time doesn't make sense. What would the best practice be for 1 daily backup and then differentials throughout the day?

SQL Server differential backup file size smaller than previous one?

I have a production system running on an SQL Server 2008 DBMS, in Full recovery mode.
I take a full backup each day at midnight, a log backup every two hours, and a differential backup every 6 hours (06:00, 12:00, 18:00, but not midnight as the full is taken then).
In recent days however I've noticed that the diff backup filesize of 18:00 is smaller than the one of 12:00. And sometimes, the one of 12:00 is smaller than the 06:00 ...
I did not experience this behavior until recent days.
Reading from the Microsoft doc, the filesize of a diff backup should always be larger than the previous one, until a new full backup is taken.
Could anyone have a possible explanation what could be causing this ?
Thanks.
I had a similar situation. I had a bit thought over it and reckoned it's caused by multiple backup jobs existing for the database, which means the differential backup was mislead by the wrong backup flag.

Resources