28 lines
868 B
C#
28 lines
868 B
C#
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() {
|
|
|
|
var ts = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
|
|
var process = new Process();
|
|
process.StartInfo.FileName = "mongodump.exe";
|
|
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();
|
|
}
|
|
}
|
|
} |