Permalink
Browse files

Don't delete the record of the last successful backup on startup

  • Loading branch information...
ayende committed Feb 10, 2012
1 parent 0293576 commit 059737c58472f7955c720799f6d40d8ed9239839
@@ -3,18 +3,32 @@
// Copyright (c) Hibernating Rhinos LTD. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
+
+using System;
+using Raven.Abstractions.Data;
using Raven.Database.Plugins;
+using Raven.Abstractions.Extensions;
namespace Raven.Database.Backup
{
/// <summary>
- /// Delete the backup status document, since it may indicate a backup was in progress when the server crashed / shutdown
+ /// Delete the backup status document, if it indicate a backup was in progress when the server crashed / shutdown
+ /// we have to do that to enable the next backup to complete
/// </summary>
public class RemoveBackupDocumentStartupTask : IStartupTask
{
public void Execute(DocumentDatabase database)
{
- database.Delete("Raven/Backup/Status", null, null);
+ var oldBackup = database.Get(BackupStatus.RavenBackupStatusDocumentKey,null);
+ if (oldBackup == null)
+ return;
+
+ var backupStatus = oldBackup.DataAsJson.JsonDeserialization<BackupStatus>();
+
+ if (backupStatus.Completed != null) // keep the record of the last successful backup
+ return;
+
+ database.Delete(BackupStatus.RavenBackupStatusDocumentKey, null, null);
}
}
}
@@ -29,7 +29,7 @@ public override System.Threading.Tasks.Task TimerTickedAsync()
if (Status == null || Status.IsRunning == false)
return null;
TaskStatus = TaskStatus.Started;
- return DatabaseCommands.GetAsync(@"Raven/Backup/Status")
+ return DatabaseCommands.GetAsync(BackupStatus.RavenBackupStatusDocumentKey)
.ContinueOnSuccessInTheUIThread(item =>
{
var documentConvention = ApplicationModel.Current.Server.Value.Conventions;

0 comments on commit 059737c

Please sign in to comment.