コード例 #1
0
ファイル: RestoreForm.cs プロジェクト: ArekX/vagrant-backup
        private void bwRestore_DoWork(object sender, DoWorkEventArgs e)
        {
            bwRestore.ReportProgress(0, "Extracting files...");
            ExtractZipFile(txtBackupFile.Text, _tempPath);


            string jsonConfig               = File.ReadAllText(Path.Combine(_tempPath, "provisioner.settings"));
            ProvisionerSettings settings    = ProvisionerSettings.ReadFromJson(jsonConfig);
            IProvisionerRestore provisioner = ProvisionRestoreResolver.GetRestoreProvisioner(settings);

            provisioner.SetProjectFolder(txtProjectFolder.Text);
            provisioner.SetSettings(settings);
            provisioner.SetSourceFolder(_tempPath);

            bwRestore.ReportProgress(60, "Importing VM...");
            VirtualBox box = new VirtualBox(_vBoxManagePath, _tempPath);

            box.ImportBox();


            bwRestore.ReportProgress(90, "Copying data...");
            DirectoryExtension.CopyRecursive(Path.Combine(_tempPath, "files"), txtProjectFolder.Text);

            provisioner.Restore(box.ImportedUUID);
            bwRestore.ReportProgress(100, "Done.");
        }
コード例 #2
0
        public static IProvisionerRestore GetRestoreProvisioner(ProvisionerSettings settings)
        {
            switch (settings.provisionerName)
            {
            case PuphpetRestore.Name:
                return(new PuphpetRestore());
            }

            return(null);
        }
コード例 #3
0
        public ProvisionerSettings GetProvisionerSettings()
        {
            ProvisionerSettings settings = new ProvisionerSettings();

            settings.provisionerName = "puphpet";

            string replacePath = _projectPath + "\\";

            settings.Set("idPath", txtIDFilePath.Text.Replace(replacePath, ""));
            settings.Set("actionProvisionPath", txtActionProvisionPath.Text.Replace(replacePath, ""));
            settings.Set("syncedFoldersPath", txtSyncedFoldersPath.Text.Replace(replacePath, ""));
            settings.Set("projectPath", _projectPath);

            return(settings);
        }
コード例 #4
0
ファイル: BackupForm.cs プロジェクト: ArekX/vagrant-backup
        private void btnBackup_Click(object sender, EventArgs e)
        {
            if (_provisioner == null) {
                return;
            }

            if (!_provisioner.CanPerformBackup()) {
                MessageBox.Show("Please fill out all provisioner settings.", "Cannot perform backup", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (string.IsNullOrWhiteSpace(txtDestination.Text)) {
                MessageBox.Show("Please fill out backup file destination.", "Cannot perform backup", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            SetControlsEnabled(false);

            ProvisionerSettings settings = _provisioner.GetProvisionerSettings();

            File.WriteAllText(Path.Combine(_tempPath, "provisioner.settings"), settings.ToJson());

            List<BackupItem> backupItems = new List<BackupItem>();
            
            foreach(BackupItem item in clbFileList.CheckedItems) {
                backupItems.Add(item);
            }

            bwBackup.RunWorkerAsync(new WorkerConfig() {
                vboxManagePath = _vBoxManagePath,
                outputPath = txtDestination.Text,
                tempPath = _tempPath,
                backupItems = backupItems,
                projectPath = txtProjectFolder.Text
            });
        }
コード例 #5
0
 public void SetSettings(ProvisionerSettings settings)
 {
     _settings = settings;
 }