diff --git a/.gitignore b/.gitignore index 5046215..7c870fa 100755 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ obj/ *.log *.json .env -data/ \ No newline at end of file +data/ +Folder.DotSettings.user diff --git a/Services/HandleDbBackup.cs b/Services/HandleDbBackup.cs index b8ee7b5..c0f1ffb 100755 --- a/Services/HandleDbBackup.cs +++ b/Services/HandleDbBackup.cs @@ -16,6 +16,7 @@ public class HandleDbBackup { logger?.LogInformation("Backup requested"); + try{ var json = (await _db.Find(new BsonDocument()).ToListAsync()).ToJson(); var bytes = Encoding.UTF8.GetBytes(json); @@ -26,5 +27,9 @@ public class HandleDbBackup DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss" + "\nCurrent post count: " + _db.CountDocumentsAsync(new BsonDocument())), ParseMode.Html); logger?.LogInformation("Backup sent"); + } + catch(Exception ex){ + logger?.LogError(ex,"Unable to backup database"); + } } } \ No newline at end of file