[longomatch] Copy instead of move the db and do it safely



commit a610e3630d1b8bbe6bb82a36ed903749ec7ece71
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Wed Apr 10 08:26:27 2013 +0200

    Copy instead of move the db and do it safely

 LongoMatch.Services/Services/DataBase.cs | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/LongoMatch.Services/Services/DataBase.cs b/LongoMatch.Services/Services/DataBase.cs
index 12cacfa..5c1f8ed 100644
--- a/LongoMatch.Services/Services/DataBase.cs
+++ b/LongoMatch.Services/Services/DataBase.cs
@@ -387,10 +387,16 @@ namespace LongoMatch.DB
                        if (File.Exists(backupFilepath))
                                File.Delete(backupFilepath);
 
-                       File.Move(file, backupFilepath);
-                       Log.Information ("Created backup for database at ", backupFilename);
-                       lastBackup = new BackupDate {Date = now};
-                       UpdateBackupDate();
+                       try {
+                               File.Copy(file, backupFilepath);
+                               Log.Information ("Created backup for database at ", backupFilename);
+                               lastBackup = new BackupDate {Date = now};
+                               UpdateBackupDate(false);
+                       } catch (Exception ex) {
+                               Log.Error("Could not create backup");
+                               Log.Exception(ex);
+                       }
+                       
                }
 
                private IQuery GetQueryProjectById(IObjectContainer db, Guid id) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]