buechermarkt/BuechermarktClient/Backup.cs

28 lines
871 B
C#
Raw Normal View History

using MongoDB.Driver;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using System.IO.Compression;
namespace BuechermarktClient
{
public class Backup
{
public static void MakeBackup() {
2017-05-21 14:23:59 +00:00
var ts = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
var process = new Process();
process.StartInfo.FileName = ".\\mongodump.exe";
2017-05-21 14:23:59 +00:00
process.StartInfo.Arguments = "--host " + MainWindow.MongoHost + " --db " + MainWindow.DatabaseName + " --gzip --out .\\backups\\" + ts;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.Start();
}
}
}