public ZfsSnapshots() : this(Zfs.ListSnapshots()) { }
public static string Delete(SnapInfo snapshot) { return(Zfs.DestroySnapshot(snapshot.Name)); }
public static string Snapshot(string filesystem) { return(Zfs.Snapshot(string.Format("{0}@{1}", filesystem, DateTime.Now.ToString("yyyy-MM-dd")))); }
static void DoBackups(IEnumerable <BackupOptions> volumes, string mountPoint) { #if GPG string pass1 = null, pass2 = null; do { if (pass1 != pass2) { Console.WriteLine("Passwords do not match."); } pass1 = ReadPassphrase("GPG passphrase"); pass2 = ReadPassphrase("again"); }while (pass1 != pass2); #endif foreach (BackupOptions vol in volumes) { if (vol.SnapshotDate == null) { continue; } Console.WriteLine(new string('#', 79)); Console.WriteLine(vol.Filesystem); if (vol.IncrementalStartDate == null) { Console.Write("Full Backup "); } else { Console.Write("{0} - ", vol.IncrementalStartDate); } Console.WriteLine(vol.SnapshotDate); Console.WriteLine(); #if GPG var mkfifo = new ProcessStartInfo(); mkfifo.FileName = "mkfifo"; mkfifo.Arguments = "z.fifo"; Process.Start(mkfifo); var tasks = new Task[2]; tasks[0] = Task.Run(() => { Zfs.Send( string.Format("{0}@{1}", vol.Filesystem, vol.SnapshotDate), Path.Combine(mountPoint, string.Format("{0}@{1}.zfs.bz2.gpg", vol.Filename, vol.SnapshotDate)), (vol.IncrementalStartDate == null) ? null : string.Format("{0}@{1}", vol.Filesystem, vol.IncrementalStartDate), "pbzip2 | gpg --symmetric --output - --passphrase-file z.fifo --batch"); }); // HACK! This shouldn't be needed! :( Thread.Sleep(100); tasks[1] = Task.Run(() => { using (var fifo = File.Open("z.fifo", FileMode.Open)) { var enc = new UnicodeEncoding(); byte[] bytes = enc.GetBytes(pass1); fifo.Write(bytes, 0, bytes.Length); fifo.Flush(true); } }); Task.WaitAll(tasks); var rm = new ProcessStartInfo(); rm.FileName = "rm"; rm.Arguments = "z.fifo"; Process.Start(rm); #else Zfs.Send( string.Format("{0}@{1}", vol.Filesystem, vol.SnapshotDate), Path.Combine(mountPoint, string.Format("{0}@{1}.zfs.bz2", vol.Filename, vol.SnapshotDate)), (vol.IncrementalStartDate == null) ? null : string.Format("{0}@{1}", vol.Filesystem, vol.IncrementalStartDate), "pbzip2"); #endif Console.WriteLine(); } }