示例#1
0
// Configure the restore job
func (r *RestoreJob) Configure(rp spec.RestoreParamiter) error {

	//configure modificaitons and reverse
	mods, err := modifications.GetModifications(rp.BackupParamiters.Modifications, true)
	if err != nil {
		return err
	}

	r.Modifications = mods

	//Confirm the Engine we want to restore from was part of the job and configure
	for _, e := range rp.BackupParamiters.Engines {
		if e.Name == rp.From.Name {
			be, err := engines.GetBackupEngines([]engines.Definition{e})
			if err != nil {
				return errors.New("Could not create restore from engine instance: " + err.Error())
			}
			r.From = &be[0]
		}
	}

	if r.From == nil {
		return errors.New("Engine to restore from must have been part of the original backup")
	}

	re, err := engines.GetRestoreEngine(rp.To)
	if err != nil {
		return err
	}
	r.To = &re

	return nil
}
示例#2
0
文件: backups.go 项目: sethjback/gobl
// AddBackup adds a backupdefinition to the system
func AddBackup(b *spec.BackupDefinition) error {
	if _, err := modifications.GetModifications(b.Paramiters.Modifications, false); err != nil {
		return err
	}
	if _, err := engines.GetBackupEngines(b.Paramiters.Engines); err != nil {
		return err
	}
	return gDb.AddBackupDefinition(b)
}
示例#3
0
// Configure verifies that all the necessary options have been provided for the modifications and eingines
// and confirms that the backup can in theory proceed
func (b *BackupJob) Configure(jobParams spec.BackupParamiter) error {
	b.Paramiters = jobParams

	mods, err := modifications.GetModifications(jobParams.Modifications, false)
	if err != nil {
		return err
	}

	b.Modifications = mods

	engines, err := engines.GetBackupEngines(jobParams.Engines)
	if err != nil {
		return err
	}

	b.Engines = engines

	b.State = "configured"

	return nil
}