Example #1
0
        private void performRestore()
        {
            string backupName = this.loadSelectedBackup();
            string filepath   = this.loadSelectedBackup();

            if (filepath == null)
            {
                return;
            }
            Database database;

            try {
                database = new Database(filepath);
            }
            catch (IOException e) {
                this.showError(e.Message);
                this.finishBackup(null, "Error");
                return;
            }
            Settings    settings    = new Settings(database);
            RestoreForm restoreForm = new RestoreForm(settings);

            restoreForm.ShowDialog();

            if (!restoreForm.Saved)
            {
                database.Close();
                return;
            }

            this.performBackupInitial();
            this.closeAfterFinish   = false;
            database.AutoSyncToDisk = true;
            Logger logger = new Logger(settings.Name + "-Restore");

            BackendBase backend;

            if (restoreForm.Backend == "Mirror")
            {
                backend = new MirrorBackend(settings.MirrorDest);
            }
            else
            {
                backend = new S3Backend(settings.S3Dest, false, settings.S3PublicKey, settings.S3PrivateKey, false);
            }

            logger.WriteRaw("\r\nStarting new restore operation\r\n\r\nSource:\t\t{0}\r\nDestination:\t{1}\r\nOverwrite files: {2}\r\nDelete files not present in backup: {3}\r\n",
                            backend.Dest, restoreForm.RestoreTo, restoreForm.Overwrite ? "yes" + (restoreForm.OverwriteOnlyIfOlder ? ", but only if older" : "") : "no",
                            restoreForm.Purge ? "yes" : "no");

            this.backgroundWorkerBackup.RunWorkerAsync(new BackupItem(restoreForm.RestoreTo, database, settings, logger, new BackendBase[] { backend }, false, true,
                                                                      restoreForm.Overwrite, restoreForm.OverwriteOnlyIfOlder, restoreForm.Purge));
        }
Example #2
0
        private void performBackup(bool fromScheduler = false)
        {
            this.performBackupInitial();

            string backup = this.loadSelectedBackup();

            if (backup == null)
            {
                return;
            }

            Database database;

            try {
                database = new Database(backup);
            }
            catch (IOException e) {
                this.showError(e.Message);
                this.finishBackup(null, "Error");
                return;
            }
            database.AutoSyncToDisk = true;
            Settings settings = new Settings(database);

            settings.LastRun = DateTime.Now;
            Logger logger = new Logger(settings.Name);

            this.updateInfoDisplay();
            this.closeAfterFinish = (fromScheduler && settings.Autoclose);

            List <BackendBase> backendBases = new List <BackendBase>();

            if (settings.MirrorEnabled)
            {
                MirrorBackend backend = new MirrorBackend(settings.MirrorDest);
                backendBases.Add(backend);
            }
            if (settings.S3Enabled)
            {
                S3Backend backend = new S3Backend(settings.S3Dest, settings.S3Test, settings.S3PublicKey, settings.S3PrivateKey, settings.S3UseRRS);
                backendBases.Add(backend);
            }

            logger.WriteRaw("\r\nStarting new backup operation\r\n\r\nSource: {0}\r\n", settings.Source);
            foreach (BackendBase backend in backendBases)
            {
                logger.WriteRaw("Backend: {0}\r\nDest: {1}\r\n", backend.Name, backend.Dest);
            }

            this.backgroundWorkerBackup.RunWorkerAsync(new BackupItem(settings.Source, settings.Database, settings, logger, backendBases.ToArray(), fromScheduler, false));
        }