0

I have make Some Differential Backup for a Database, which will take the Backup for the Last Modified Data which will be appended to the previously happend Full Backup file. Now, when i am trying to take Restore of the .bak file entire Data is getting Backup, is it possible to take the Backup only the Last Backup taken data i wanted? Can, any one help me on this.

private void RestoreDataBase(Server MyServer, Database MyDataBase, string DevicePath, string Type)
     {
         try
         {
             progressBar1.Value = 0;
             Restore restoreDB = new Restore();
             restoreDB.Action = RestoreActionType.Database;
             restoreDB.Database = MyDataBase.Name;
             restoreDB.Devices.AddDevice(DevicePath, DeviceType.File);
             restoreDB.ReplaceDatabase = true;
             restoreDB.NoRecovery = true;
             restoreDB.PercentComplete += new PercentCompleteEventHandler(rstDatabase_PercentComplete);
             restoreDB.Complete += new ServerMessageEventHandler(rstDatabase_Complete);
             restoreDB.SqlRestore(MyServer);
         }
         catch (Exception ex)
         {
             WriteToListView(ex.Message.ToString());
             writetoLog(ex.Message.ToString());
         }
     }

The above is the coding i am using, and the database is Sql Server 2008, The coding i am using for Differential Backup is as follows

private void BackupDataBaseDifferential(Server MyServer, Database MyDataBase, string DestinationPath, string Type)
     {
         try
         {
             WriteToListView("Taking the Differential Backup for " + MyDataBase.Name);
             Backup backDB = new Backup();
             backDB.Action = BackupActionType.Database;
             backDB.Database = MyDataBase.Name;
             backDB.Devices.AddDevice(DestinationPath, DeviceType.File);
             backDB.BackupSetName = "Sql Database Backup Differential";
             backDB.BackupSetDescription = "Sql Database Backup - DifferentialType";
             backDB.ExpirationDate = DateTime.Now.AddDays(5);
             backDB.Initialize = false;
             backDB.Incremental = true;
             if (Type == "Manual")
             {
                 progressBar1.Value = 0;
                 backDB.PercentComplete += new PercentCompleteEventHandler(bd_PercentComplete);
                 backDB.Complete += new ServerMessageEventHandler(bd_Complete);
             }
             else if (Type == "Automatic")
             {
                 backDB.PercentComplete += CompletionStatusInPercent;
                 backDB.Complete += Backup_Completed;
             }
             backDB.SqlBackup(MyServer);
         }
         catch (Exception ex)
         {
             WriteToListView(ex.Message.ToString());
             writetoLog(ex.Message.ToString());
         }
     }

So, if i use the above coding the last data which is modified in the Database (which was already taken Backup Fully previously) will be taken. So, my problem is when i use the RestoreDataBase() method the entire Database is getting restore, bcoz all the Full Backup data and the Differential Backup data will be in only one file ex: Sample.bak. If i want only the last modified data is it not possible to take by Specifying the Date of the Data modified to the Database?

2
  • 1
    You have a better chance of getting a useful answer if you provide as much information as possible. In your case that would include: Which database system are you using and what is the code you are using to restore? Commented Apr 8, 2011 at 7:51
  • And more: which app did you use to create full/partial backups? Some commercial one or a self-made? Commented Apr 8, 2011 at 7:55

1 Answer 1

0

Maybe silly, but if you export your db as .sql, when you need to restore only some data, you can read file and "filter" rows to restore...
Anyway there is another thread talking about this, take a look here.

Sign up to request clarification or add additional context in comments.

1 Comment

Ok, thank u @Marco. But i dint find any information regarding my problem in that site.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.