예제 #1
0
        private void Inc_Backup(fullBackupInfo backup, backup_source source, backup_target target)
        {
            string targetPath = target.path;

            targetPath += @"\inc\";

            bool ZIP = backup.format_type == "zip";

            targetPath = fileFunc.CheckDirectoriesGetRealName(targetPath, ZIP);

            if (Directory.GetDirectories(targetPath).Length == 0 && Directory.GetFiles(targetPath).Length == 0)
            {
                snapshotFunc.SaveSnapshot(source.path, targetPath);

                targetPath += AddDate();

                if (ZIP)
                {
                    ZipFile.CreateFromDirectory(source.path, targetPath + ".zip");
                }
                else
                {
                    fileFunc.Copy(source.path, targetPath);
                }
            }
            else
            {
                List <snapshot> rs = snapshotFunc.ReadPreviousSnapshot(targetPath);
                List <snapshot> cs = snapshotFunc.GetSnapshotList(source.path);

                snapshotFunc.SaveSnapshot(source.path, targetPath);

                snapshotFunc.SaveDeleted(rs, cs, targetPath);
                List <snapshot> difference = snapshotFunc.GetSnapshotDifference(rs, cs);

                if (ZIP)
                {
                    string targetPathZ = targetPath + AddDate();

                    fileFunc.Copy(source.path, targetPathZ, difference);
                    ZipFile.CreateFromDirectory(targetPathZ, targetPathZ + ".zip");
                    Directory.Delete(targetPathZ, true);
                }
                else
                {
                    fileFunc.Copy(source.path, targetPath + AddDate(), difference);
                }
            }

            fileFunc.DeleteOldBackups(target.path + @"\inc\", ZIP);
        }
예제 #2
0
        private void Full_Backup(fullBackupInfo backup, backup_source source, backup_target target)
        {
            string targetPath = target.path;

            targetPath += @"\full\";

            bool ZIP = backup.format_type == "zip";

            fileFunc.CheckParentDirectory(targetPath, ZIP);

            if (ZIP)
            {
                ZipFile.CreateFromDirectory(source.path, targetPath + AddDate() + ".zip");
            }
            else
            {
                fileFunc.Copy(source.path, targetPath + AddDate());
            }

            fileFunc.DeleteOldBackups(target.path + @"\full\", ZIP);

            HttpRequests.PostJobHistory(backup.id, DateTime.Now, true);
        }