Example #1
0
        private static int UpdateOrCreateSettingsFile()
        {
            var configFile     = GetConfigFile();
            var backupSettings = File.Exists(configFile) ? BackupSettings.LoadBackupSettings(configFile) : new BackupSettings();

            var passwordSettingsDialog = new PasswordSettingsDialog();

            if (passwordSettingsDialog.ShowDialog() == DialogResult.OK)
            {
                if (!string.IsNullOrWhiteSpace(passwordSettingsDialog.ArchivePassword))
                {
                    backupSettings.ArchivePassword = SecurityHelpers.EncodeSecret(passwordSettingsDialog.ArchivePassword);
                }

                if (!string.IsNullOrWhiteSpace(passwordSettingsDialog.FTPPassword))
                {
                    backupSettings.FTPSettings.FTPPassword = SecurityHelpers.EncodeSecret(passwordSettingsDialog.FTPPassword);
                }

                if (!string.IsNullOrWhiteSpace(passwordSettingsDialog.EmailPassword))
                {
                    backupSettings.EmailSettings.EmailPassword = SecurityHelpers.EncodeSecret(passwordSettingsDialog.EmailPassword);
                }

                //Create a backup of the existing config file
                if (File.Exists(configFile))
                {
                    File.Copy(configFile, configFile + ".bak", true);
                }

                backupSettings.SaveBackupSettings(configFile);
            }
            return(ExitCodeSuccess);
        }
Example #2
0
        private static int RunBackup(bool forceFull)
        {
            var configFile = GetConfigFile();

            if (!File.Exists(configFile))
            {
                Console.WriteLine("Configuration file [config.xml] does not exist. Run program with /C switch to create one.");
                return(ExitCodeFail);
            }

            var p = new BackupEngine(BackupSettings.LoadBackupSettings(configFile));

            return(p.PerformBackups(forceFull) ? ExitCodeSuccess : ExitCodeFail);
        }
Example #3
0
 internal BackupEngine(BackupSettings backupSettings)
 {
     this.backupSettings = backupSettings;
 }
Example #4
0
 internal BackupEngine(BackupSettings backupSettings)
 {
     this.backupSettings = backupSettings;
 }