예제 #1
0
        static void Main(string[] args)
        {
            Display.SetWindowStyle(ProcessWindowStyle.Hidden);

            // init config file (and current log file)
            BackupArchiverConfig config = new BackupArchiverConfig(args);
            if (!config.IsSetConfig)
            {
                //Log.Add("Config file is not set. Exit..");
                OnFinish(config);
                return;
            }

            //ProcessWindowStyle windowStyle = config.WindowStyle;
            Display.SetWindowStyle(config.WindowStyle);

            // check 7zip existing
            Zip.Init(config.ZipPath);
            if (!Zip.IsExist)
            {
                OnFinish(config);
                //Log.Add("'7zip' is missing! Exit..");
                //Console.ReadLine();
                return;
            }
            //else Log.Add("'7zip' on base");

            // archiving
            List<Folder> folders = config.Folders;
            if (folders != null)
            {
                int i = 1;
                foreach (Folder folder in folders)
                {
                    Log.AddLine();
                    Log.Add(">>> Task {0}", i);

                    string archiveName = folder.HeadMask + String.Format(config.TailMask, DateTime.Now);
                    if (Zip.AddToZipArchive(folder.SourcePath, folder.DestPath, archiveName, config.ZipArgs) == ZipCodes.NoError.Value)
                        // delete old archives if no errors
                        FileSystem.DeleteOldFiles(folder.DestPath, folder.MaxArchives, folder.HeadMask + "*");
                    else Log.Add("Deleting old files in [{0}] will not be", folder.DestPath);

                    Log.Add("<<< Task {0}", i);
                    i++;
                }
            }
            else Log.Add("Error in config ([Folders] == null");

            // delete extra log files
            //Log.AddLine();
            //FileSystem.DeleteOldFiles(config.LogPath, config.MaxLogs, "*.log");

            //Log.Add("Finish");
            OnFinish(config);
        }
예제 #2
0
        static void Main(string[] args)
        {
            Display.SetWindowStyle(ProcessWindowStyle.Hidden);

            // init config file (and current log file)
            BackupArchiverConfig config = new BackupArchiverConfig(args);

            if (!config.IsSetConfig)
            {
                //Log.Add("Config file is not set. Exit..");
                OnFinish(config);
                return;
            }

            //ProcessWindowStyle windowStyle = config.WindowStyle;
            Display.SetWindowStyle(config.WindowStyle);

            // check 7zip existing
            Zip.Init(config.ZipPath);
            if (!Zip.IsExist)
            {
                OnFinish(config);
                //Log.Add("'7zip' is missing! Exit..");
                //Console.ReadLine();
                return;
            }
            //else Log.Add("'7zip' on base");

            // archiving
            List <Folder> folders = config.Folders;

            if (folders != null)
            {
                int i = 1;
                foreach (Folder folder in folders)
                {
                    Log.AddLine();
                    Log.Add(">>> Task {0}", i);

                    string archiveName = folder.HeadMask + String.Format(config.TailMask, DateTime.Now);
                    if (Zip.AddToZipArchive(folder.SourcePath, folder.DestPath, archiveName, config.ZipArgs) == ZipCodes.NoError.Value)
                    {
                        // delete old archives if no errors
                        FileSystem.DeleteOldFiles(folder.DestPath, folder.MaxArchives, folder.HeadMask + "*");
                    }
                    else
                    {
                        Log.Add("Deleting old files in [{0}] will not be", folder.DestPath);
                    }

                    Log.Add("<<< Task {0}", i);
                    i++;
                }
            }
            else
            {
                Log.Add("Error in config ([Folders] == null");
            }

            // delete extra log files
            //Log.AddLine();
            //FileSystem.DeleteOldFiles(config.LogPath, config.MaxLogs, "*.log");

            //Log.Add("Finish");
            OnFinish(config);
        }