// Restore pops the latest transform from the stack.
5438
func (p *Painter) Restore() {
	if len(p.transforms) > 0 {
		p.transforms = p.transforms[:len(p.transforms)-1]
	}
}
305694
func (r *AllocationBitmap) Restore(rangeSpec string, data []byte) error {
	r.lock.Lock()
	defer r.lock.Unlock()

	if r.rangeSpec != rangeSpec {
		return errors.New("the provided range does not match the current range")
	}

	r.allocated = big.NewInt(0).SetBytes(data)
	r.count = countBits(r.allocated)

	return nil
}
705859
func (c *Files) Restore(in *RestoreInput) (out *RestoreOutput, err error) {
	body, err := c.call("/files/restore", in)
	if err != nil {
		return
	}
	defer body.Close()

	err = json.NewDecoder(body).Decode(&out)
	return
}
816489
func (dao *ControlPlaneDao) Restore(restoreRequest model.RestoreRequest, _ *int) (err error) {
	ctx := datastore.Get()
	if len(restoreRequest.Username) > 0 {
		ctx.SetUser(restoreRequest.Username)
	}
	dfslocker := dao.facade.DFSLock(ctx)
	dfslocker.Lock("restore")
	defer dfslocker.Unlock()
	inprogress.SetProgress(restoreRequest.Filename, "restore")
	defer func() {
		if err != nil {
			log.WithError(err).Error("Restore failed with error")
		}
		inprogress.SetError(err)
	}()
	info, err := dfs.ExtractBackupInfo(restoreRequest.Filename)
	if err != nil {
		return err
	}
	fh, err := os.Open(restoreRequest.Filename)
	if err != nil {
		return err
	}
	defer fh.Close()
	gz, err := gzip.NewReader(fh)
	if err != nil {
		return err
	}
	defer gz.Close()
	err = dao.facade.Restore(ctx, gz, info, restoreRequest.Filename)
	return err
}
52678
func (s *CloudBackupServer) Restore(
	ctx context.Context,
	req *api.SdkCloudBackupRestoreRequest,
) (*api.SdkCloudBackupRestoreResponse, error) {
	if s.driver(ctx) == nil {
		return nil, status.Error(codes.Unavailable, "Resource has not been initialized")
	}
	credId := req.GetCredentialId()
	var err error
	if len(req.GetBackupId()) == 0 {
		return nil, status.Error(codes.InvalidArgument, "Must provide backup id")
	} else if len(req.GetCredentialId()) == 0 {
		credId, err = s.defaultCloudBackupCreds(ctx)
		if err != nil {
			return nil, err
		}
	}

	if len(req.GetCredentialId()) != 0 {
		if err := s.checkAccessToCredential(ctx, req.GetCredentialId()); err != nil {
			return nil, err
		}
	}

	r, err := s.driver(ctx).CloudBackupRestore(&api.CloudBackupRestoreRequest{
		ID:                req.GetBackupId(),
		RestoreVolumeName: req.GetRestoreVolumeName(),
		CredentialUUID:    credId,
		NodeID:            req.GetNodeId(),
		Name:              req.GetTaskId(),
	})
	if err != nil {
		return nil, status.Errorf(codes.Internal, "Failed to restore backup: %v", err)
	}

	return &api.SdkCloudBackupRestoreResponse{
		RestoreVolumeId: r.RestoreVolumeID,
		TaskId:          r.Name,
	}, nil

}
554733
func (context *ElasticRuntime) Restore() (err error) {
	err = context.backupRestore(cfbackup.ImportArchive)
	return
}
408815
func (p *Plot) Restore() *Plot {
	if p.env.parent == nil {
		panic("unbalanced Save/Restore")
	}
	p.env = p.env.parent
	return p
}
1086970
func (client *FakeTabletManagerClient) RestoreFromBackup(ctx context.Context, tablet *topodatapb.Tablet) (logutil.EventStream, error) {
	return &eofEventStream{}, nil
}
1262573
func (c *Connection) Restore(dbConn *sdb.Conn, s *Store) {
	c.dbMu.Lock()
	defer c.dbMu.Unlock()
	c.db = dbConn
	c.store = s
	c.logger = log.New(os.Stderr, connectionLogPrefix(c.ID), log.LstdFlags)
}
1194814
func (a *API) Restore(p params.RestoreArgs) error {
	logger.Infof("Starting server side restore")

	// Get hold of a backup file Reader
	backup, closer := newBackups(a.backend)
	defer closer.Close()

	// Obtain the address of current machine, where we will be performing restore.
	machine, err := a.backend.Machine(a.machineID)
	if err != nil {
		return errors.Trace(err)
	}

	addr, err := machine.PrivateAddress()
	if err != nil {
		return errors.Annotatef(err, "error fetching internal address for machine %q", machine)
	}

	publicAddress, err := machine.PublicAddress()
	if err != nil {
		return errors.Annotatef(err, "error fetching public address for machine %q", machine)
	}

	info := a.backend.RestoreInfo()
	// Signal to current state and api server that restore will begin
	err = info.SetStatus(state.RestoreInProgress)
	if err != nil {
		return errors.Annotatef(err, "cannot set the server to %q mode", state.RestoreInProgress)
	}
	// Any abnormal termination of this function will mark restore as failed,
	// successful termination will call Exit and never run this.
	defer info.SetStatus(state.RestoreFailed)

	instanceId, err := machine.InstanceId()
	if err != nil {
		return errors.Annotate(err, "cannot obtain instance id for machine to be restored")
	}

	logger.Infof("beginning server side restore of backup %q", p.BackupId)
	// Restore
	restoreArgs := backups.RestoreArgs{
		PrivateAddress: addr.Value,
		PublicAddress:  publicAddress.Value,
		NewInstId:      instanceId,
		NewInstTag:     machine.Tag(),
		NewInstSeries:  machine.Series(),
	}

	session := a.backend.MongoSession().Copy()
	defer session.Close()

	// Don't go if HA isn't ready.
	err = waitUntilReady(session, 60)
	if err != nil {
		return errors.Annotatef(err, "HA not ready; try again later")
	}

	oldTagString, err := backup.Restore(p.BackupId, restoreArgs)
	if err != nil {
		return errors.Annotate(err, "restore failed")
	}

	// A backup can be made of any component of an ha array.
	// The files in a backup don't contain purely relativized paths.
	// If the backup is made of the bootstrap node (machine 0) the
	// recently created machine will have the same paths and therefore
	// the startup scripts will fit the new juju. If the backup belongs
	// to a different machine, we need to create a new set of startup
	// scripts and exit with 0 (so that the current script does not try
	// to restart the old juju, which will no longer be there).
	if oldTagString != nil && oldTagString != bootstrapNode {
		srvName := fmt.Sprintf("jujud-%s", oldTagString)
		srv, err := service.DiscoverService(srvName, common.Conf{})
		if err != nil {
			return errors.Annotatef(err, "cannot find %q service", srvName)
		}
		if err := srv.Start(); err != nil {
			return errors.Annotatef(err, "cannot start %q service", srvName)
		}
		// We dont want machine-0 to restart since the new one has a different tag.
		// We started the new one above.
		os.Exit(0)
	}

	// After restoring, the api server needs a forced restart, tomb will not work
	// this is because we change all of juju configuration files and mongo too.
	// Exiting with 0 would prevent upstart to respawn the process

	// NOTE(fwereade): the apiserver needs to be restarted, yes, but
	// this approach is completely broken. The only place it's ever
	// ok to use os.Exit is in a main() func that's *so* simple as to
	// be reasonably left untested.
	//
	// And passing os.Exit in wouldn't make this any better either,
	// just using it subverts the expectations of *everything* else
	// running in the process.
	// XXX: We have ErrRestartAgent which should be capable of replacing this
	os.Exit(1)
	return nil
}
1056631
func (f *Facade) Restore(ctx datastore.Context, r io.Reader, backupInfo *dfs.BackupInfo, backupFilename string) error {
	defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.Restore"))
	// Do not DFSLock here, ControlPlaneDao does that
	stime := time.Now()
	plog.Info("Started restore from backup")
	alog := f.auditLogger.Message(ctx, "Started Restoring from Backup").Action(audit.Restore).
			WithFields(logrus.Fields{
				"backupfile": backupFilename,
				"starttime": stime.UTC().Format("2006-01-02-150405"),
			})
	alog.Succeeded()
	if err := f.dfs.Restore(r, backupInfo.BackupVersion); err != nil {
		plog.WithError(err).Debug("Could not restore from backup")
		return alog.Error(err)
	}
	if err := f.RestoreServiceTemplates(ctx, backupInfo.Templates); err != nil {
		plog.WithError(err).Debug("Could not restore service templates from backup")
		return alog.Error(err)
	}
	plog.Infof("Restored service templates")
	if err := f.RestoreResourcePools(ctx, backupInfo.Pools); err != nil {
		plog.WithError(err).Debug("Could not restore resource pools from backup")
		return alog.Error(err)
	}
	plog.Info("Restored resource pools")
	for _, snapshot := range backupInfo.Snapshots {
		logger := plog.WithField("snapshot", snapshot)
		if err := f.Rollback(ctx, snapshot, false); err != nil {
			logger.WithError(err).Debug("Could not rollback snapshot")
			return alog.Error(err)
		} else {
			logger.Info("Rolled back snapshot")
			if err := f.dfs.Delete(snapshot); err != nil {
				// if we couldn't delete, untag it so the TTL reaper will get it eventually
				info, err := f.dfs.Info(snapshot)
				if err != nil {
					logger.WithError(err).Warning("Could not get info for snapshot.")
				} else if len(info.Tags) > 0 {
					if _, err := f.dfs.Untag(info.TenantID, info.Tags[0]); err != nil {
						logger.WithError(err).Warning("Could not untag snapshot.  Snapshot must be deleted manually!")
					} else {
						logger.Info("Snapshot from backup untagged.")
					}
				}
			} else {
				logger.Info("Removed snapshot after rollback")
			}
		}

	}
	restoreDuration := time.Since(stime)
	plog.Info("Completed restore from backup")
	alog = f.auditLogger.Message(ctx, "Completed Restoring from Backup").Action(audit.Restore).
		WithFields(logrus.Fields{
			"backupfile": backupFilename,
			"elapsed": fmt.Sprintf("%fsec", restoreDuration.Seconds()),
		})
	alog.Succeeded()
	return nil
}
1036020
func (_m *DFS) Restore(r io.Reader, version int) error {
	ret := _m.Called(r, version)

	var r0 error
	if rf, ok := ret.Get(0).(func(io.Reader, int) error); ok {
		r0 = rf(r, version)
	} else {
		r0 = ret.Error(0)
	}

	return r0
}
355889
func (g *Group) Recover() *Statement {
	s := Recover()
	g.items = append(g.items, s)
	return s
}
119999
func (deploy *Deploy) Restore() (*Response, error) {
	return deploy.client.Request("POST", path.Join(deploy.apiPath(), "restore"), nil, deploy)
}
520869
func (c *PodConfig) Restore(path string, updates chan<- interface{}) error {
	if c.checkpointManager != nil {
		return nil
	}
	var err error
	c.checkpointManager, err = checkpointmanager.NewCheckpointManager(path)
	if err != nil {
		return err
	}
	pods, err := checkpoint.LoadPods(c.checkpointManager)
	if err != nil {
		return err
	}
	updates <- kubetypes.PodUpdate{Pods: pods, Op: kubetypes.RESTORE, Source: kubetypes.ApiserverSource}
	return nil
}
1141620
func Restore(fd int, state *State) error {
	return fmt.Errorf("terminal: Restore not implemented on %s/%s", runtime.GOOS, runtime.GOARCH)
}
242737
func (a *Agent) restoreCheckState(snap map[types.CheckID]*structs.HealthCheck) {
	for id, check := range snap {
		a.State.UpdateCheck(id, check.Status, check.Output)
	}
}