lxd/backup.go
func backupCreate(s *state.State, args db.ContainerBackupArgs, sourceContainer container) error {
	// Create the database entry
	err := s.Cluster.ContainerBackupCreate(args)
	if err != nil {
		if err == db.ErrAlreadyDefined {
			return fmt.Errorf("backup '%s' already exists", args.Name)
		}

		return errors.Wrap(err, "Insert backup info into database")
	}

	// Get the backup struct
	b, err := backupLoadByName(s, sourceContainer.Project(), args.Name)
	if err != nil {
		return errors.Wrap(err, "Load backup object")
	}

	// Now create the empty snapshot
	err = sourceContainer.Storage().ContainerBackupCreate(*b, sourceContainer)
	if err != nil {
		s.Cluster.ContainerBackupRemove(args.Name)
		return errors.Wrap(err, "Backup storage")
	}

	return nil
}
func backupCreate(s *state.State, args db.ContainerBackupArgs, sourceContainer container) error {
	// Create the database entry
	err := s.Cluster.ContainerBackupCreate(args)
	if err != nil {
		if err == db.ErrAlreadyDefined {
			return fmt.Errorf("backup '%s' already exists", args.Name)
		}

		return errors.Wrap(err, "Insert backup info into database")
	}

	// Get the backup struct
	b, err := backupLoadByName(s, sourceContainer.Project(), args.Name)
	if err != nil {
		return errors.Wrap(err, "Load backup object")
	}

	// Now create the empty snapshot
	err = sourceContainer.Storage().ContainerBackupCreate(*b, sourceContainer)
	if err != nil {
		s.Cluster.ContainerBackupRemove(args.Name)
		return errors.Wrap(err, "Backup storage")
	}

	return nil
}
func backupCreate ( s * state . State , args db . ContainerBackupArgs , sourceContainer container ) error { // Create the database entry err := s . Cluster . ContainerBackupCreate ( args ) if err != nil { if err == db . ErrAlreadyDefined { return fmt . Errorf ( " " , args . Name ) } return errors . Wrap ( err , " " ) } // Get the backup struct b , err := backupLoadByName ( s , sourceContainer . Project ( ) , args . Name ) if err != nil { return errors . Wrap ( err , " " ) } // Now create the empty snapshot err = sourceContainer . Storage ( ) . ContainerBackupCreate ( * b , sourceContainer ) if err != nil { s . Cluster . ContainerBackupRemove ( args . Name ) return errors . Wrap ( err , " " ) } return nil }
// Create a new backup
Create a new backup