Beispiel #1
0
        public ABackup(PlannedBackups item)
        {
            Console.WriteLine($"{item.BackupType} backup in progress");
            try
            {
                this.SourcePaths = JsonConvert.DeserializeObject <List <string> >(item.SourcePath);
            }
            catch
            {
                this.SourcePaths = new List <string>()
                {
                    item.SourcePath
                };
            }

            try
            {
                this.DestinationPaths = JsonConvert.DeserializeObject <List <string> >(item.DestinationPath);
            }
            catch
            {
                this.DestinationPaths = new List <string>()
                {
                    item.DestinationPath
                };
            }

            this.backup = item;
            this.Start();
        }
Beispiel #2
0
        public static bool ZipFiles(List <string> destinationPaths, PlannedBackups backup)
        {
            bool   toRet    = true;
            string filename = "";
            string tempPath = Path.GetTempPath();

            foreach (string item in destinationPaths)
            {
                try
                {
                    File.Delete($"{tempPath}//backup.zip");
                    ZipFile.CreateFromDirectory(item, $"{tempPath}//backup.zip", CompressionLevel.Optimal, false);
                }
                catch { toRet = false; continue; }

                if (backup.Override)
                {
                    try
                    {
                        Directory.Delete(item, true);
                        Directory.CreateDirectory(item);
                        File.Copy($"{tempPath}//backup.zip", $"{item}//backup.zip", true);
                    }
                    catch { toRet = false; continue; }
                }
                else
                {
                    try
                    {
                        int cnt = 0;
                        foreach (string file in Directory.GetFiles(item, "*", SearchOption.TopDirectoryOnly))
                        {
                            if (file.Contains("backup"))
                            {
                                cnt++;
                            }
                        }
                        File.Copy($"{tempPath}//backup.zip", $"{item}//backup_{cnt}.zip", true);
                    }
                    catch { toRet = false; continue; }
                }
            }
            return(toRet);
        }
Beispiel #3
0
        public static bool Ftp(List <string> destinationPaths, PlannedBackups backup)
        {
            bool ret = true;

            ZipFiles(destinationPaths, backup);
            string path = Path.GetTempPath() + "//backup.zip";

            foreach (FtpSettings item in DaemonSettings.ftpSettings)
            {
                if (ret == true)
                {
                    ret = SendFtp(item, path);
                }
                else
                {
                    SendFtp(item, path);
                }
            }
            return(ret);
        }
Beispiel #4
0
 public FullBackup(PlannedBackups item) : base(item)
 {
 }
 public DifferentialBackup(PlannedBackups item) : base(item)
 {
 }
Beispiel #6
0
 public IncrementalBackup(PlannedBackups item) : base(item)
 {
 }