Esempio n. 1
0
func (d *Driver) CreateBackup(snapshotID, volumeID, destURL string, opts map[string]string) (string, error) {
	d.mutex.Lock()
	defer d.mutex.Unlock()

	volume := d.blankVolume(volumeID)
	if err := util.ObjectLoad(volume); err != nil {
		return "", err
	}

	objVolume := &objectstore.Volume{
		Name:        volumeID,
		Driver:      d.Name(),
		Size:        volume.Size,
		CreatedTime: opts[convoydriver.OPT_VOLUME_CREATED_TIME],
	}
	objSnapshot := &objectstore.Snapshot{
		Name:        snapshotID,
		CreatedTime: opts[convoydriver.OPT_SNAPSHOT_CREATED_TIME],
	}
	return objectstore.CreateDeltaBlockBackup(objVolume, objSnapshot, destURL, d)
}
Esempio n. 2
0
func (d *Driver) CreateBackup(snapshotID, volumeID, destURL string, opts map[string]string) (string, error) {
	volume := d.blankVolume(volumeID)
	if err := util.ObjectLoad(volume); err != nil {
		return "", err
	}

	objVolume := &objectstore.Volume{
		UUID:        volumeID,
		Name:        opts[convoydriver.OPT_VOLUME_NAME],
		Driver:      d.Name(),
		Size:        volume.Size,
		FileSystem:  opts[convoydriver.OPT_FILESYSTEM],
		CreatedTime: opts[convoydriver.OPT_VOLUME_CREATED_TIME],
	}
	objSnapshot := &objectstore.Snapshot{
		UUID:        snapshotID,
		Name:        opts[convoydriver.OPT_SNAPSHOT_NAME],
		CreatedTime: opts[convoydriver.OPT_SNAPSHOT_CREATED_TIME],
	}
	return objectstore.CreateDeltaBlockBackup(objVolume, objSnapshot, destURL, d)
}
Esempio n. 3
0
func doBackupCreate(c *cli.Context) error {
	var (
		err         error
		backingFile *replica.BackingFile
	)

	destURL, err := util.GetFlag(c, "dest", true, err)
	if err != nil {
		return err
	}

	snapshotName, err := getName(c, "", true)
	if err != nil {
		return err
	}

	volumeName, err := util.GetFlag(c, "volume", true, err)
	if err != nil {
		return err
	}

	dir, err := os.Getwd()
	if err != nil {
		return err
	}

	volumeInfo, err := replica.ReadInfo(dir)
	if err != nil {
		return err
	}
	if volumeInfo.BackingFileName != "" {
		backingFileName := volumeInfo.BackingFileName
		if _, err := os.Stat(backingFileName); err != nil {
			return err
		}

		backingFile, err = openBackingFile(backingFileName)
		if err != nil {
			return err
		}
	}
	replicaBackup := replica.NewBackup(backingFile)

	volume := &objectstore.Volume{
		Name:        volumeName,
		Driver:      DRIVERNAME,
		Size:        volumeInfo.Size,
		CreatedTime: util.Now(),
	}
	snapshot := &objectstore.Snapshot{
		Name:        snapshotName,
		CreatedTime: util.Now(),
	}

	log.Debugf("Starting backup for %v, snapshot %v, dest %v", volume, snapshot, destURL)
	backupURL, err := objectstore.CreateDeltaBlockBackup(volume, snapshot, destURL, replicaBackup)
	if err != nil {
		return err
	}
	fmt.Println(backupURL)
	return nil
}