// backup steps back one rune. Can be called only twice between calls to next.
431645
func (lx *lexer) backup() {
	if lx.atEOF {
		lx.atEOF = false
		return
	}
	if lx.nprev < 1 {
		panic("backed up too far")
	}
	w := lx.prevWidths[0]
	lx.prevWidths[0] = lx.prevWidths[1]
	lx.prevWidths[1] = lx.prevWidths[2]
	lx.nprev--
	lx.pos -= w
	if lx.pos < len(lx.input) && lx.input[lx.pos] == '\n' {
		lx.line--
	}
}
696014
func (b *BackupEngine) CreateNewBackup(db *DB) error {
	var cErr *C.char

	C.rocksdb_backup_engine_create_new_backup(b.c, db.c, &cErr)
	if cErr != nil {
		defer C.free(unsafe.Pointer(cErr))
		return errors.New(C.GoString(cErr))
	}

	return nil
}
781712
func (bs backups) Less(i, j int) bool {
	timeLayout := "2006-01-02 15:04:05" // oh my : https://golang.org/src/time/format.go
	t1, _ := time.Parse(timeLayout, bs[i].Created)
	t2, _ := time.Parse(timeLayout, bs[j].Created)
	return t1.After(t2)
}
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

}
1054
func (l *List) Back() *Element {
	if l.len == 0 {
		return nil
	}
	return l.root.prev
}
267428
func (s *CreateBackupOutput) SetBackup(v *Backup) *CreateBackupOutput {
	s.Backup = v
	return s
}
488967
func (c *SQLiteConn) Backup(dest string, conn *SQLiteConn, src string) (*SQLiteBackup, error) {
	destptr := C.CString(dest)
	defer C.free(unsafe.Pointer(destptr))
	srcptr := C.CString(src)
	defer C.free(unsafe.Pointer(srcptr))

	if b := C.sqlite3_backup_init(c.db, destptr, conn.db, srcptr); b != nil {
		bb := &SQLiteBackup{b: b}
		runtime.SetFinalizer(bb, (*SQLiteBackup).Finish)
		return bb, nil
	}
	return nil, c.lastError()
}
1302286
func (client *FakeTabletManagerClient) Backup(ctx context.Context, tablet *topodatapb.Tablet, concurrency int, allowMaster bool) (logutil.EventStream, error) {
	return &eofEventStream{}, nil
}
298541
func Backoff(operation func() (*Response, error), options ...Option) error {
	// Defaults
	opts := Options{
		maxRetries:      defaultMaxRetries,
		waitTime:        defaultWaitTime,
		maxWaitTime:     defaultMaxWaitTime,
		retryConditions: []RetryConditionFunc{},
	}

	for _, o := range options {
		o(&opts)
	}

	var (
		resp *Response
		err  error
	)
	base := float64(opts.waitTime)        // Time to wait between each attempt
	capLevel := float64(opts.maxWaitTime) // Maximum amount of wait time for the retry
	for attempt := 0; attempt < opts.maxRetries; attempt++ {
		resp, err = operation()

		var needsRetry bool
		var conditionErr error
		for _, condition := range opts.retryConditions {
			needsRetry, conditionErr = condition(resp)
			if needsRetry || conditionErr != nil {
				break
			}
		}

		// If the operation returned no error, there was no condition satisfied and
		// there was no error caused by the conditional functions.
		if err == nil && !needsRetry && conditionErr == nil {
			return nil
		}
		// Adding capped exponential backup with jitter
		// See the following article...
		// http://www.awsarchitectureblog.com/2015/03/backoff.html
		temp := math.Min(capLevel, base*math.Exp2(float64(attempt)))
		ri := int(temp / 2)
		if ri <= 0 {
			ri = 1<<31 - 1 // max int for arch 386
		}
		sleepDuration := time.Duration(math.Abs(float64(ri + rand.Intn(ri))))

		if sleepDuration < opts.waitTime {
			sleepDuration = opts.waitTime
		}
		time.Sleep(sleepDuration)
	}

	return err
}
954096
func (_m *DFS) BackupInfo(r io.Reader) (*dfs.BackupInfo, error) {
	ret := _m.Called(r)

	var r0 *dfs.BackupInfo
	if rf, ok := ret.Get(0).(func(io.Reader) *dfs.BackupInfo); ok {
		r0 = rf(r)
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).(*dfs.BackupInfo)
		}
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(io.Reader) error); ok {
		r1 = rf(r)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
733982
func (s *Store) Backup(leader bool, fmt BackupFormat, dst io.Writer) error {
	s.restoreMu.RLock()
	defer s.restoreMu.RUnlock()

	if leader && s.raft.State() != raft.Leader {
		return ErrNotLeader
	}

	var err error
	if fmt == BackupBinary {
		err = s.database(leader, dst)
		if err != nil {
			return err
		}
	} else if fmt == BackupSQL {
		if err := s.dbConn.Dump(dst); err != nil {
			return err
		}
	} else {
		return ErrInvalidBackupFormat
	}
	stats.Add(numBackups, 1)
	return nil
}
431495
func (snapshot *Snapshot) Rollback() error {
	var c_snapname *C.char = C.CString(snapshot.name)
	defer C.free(unsafe.Pointer(c_snapname))

	return GetError(C.rbd_snap_rollback(snapshot.image.image, c_snapname))
}
560612
func (api *DatabaseAPI) Backup(id int64) (string, error) {
	var (
		method = "POST"
		uri    = fmt.Sprintf("%s/%d/action/history", api.getResourceURL(), id)
	)

	body := map[string]interface{}{
		"Appliance": map[string]interface{}{
			"Settings": map[string]interface{}{
				"DBConf": map[string]interface{}{
					"backup": map[string]string{
						"availability": "discontinued",
					},
				},
			},
		},
	}

	res := &databaseBackupResponse{}
	err := api.baseAPI.request(method, uri, body, res)
	if err != nil {
		return "", err
	}
	return res.Log, nil
}
371083
func (_m *DFS) Backup(info dfs.BackupInfo, w io.Writer) error {
	ret := _m.Called(info, w)

	var r0 error
	if rf, ok := ret.Get(0).(func(dfs.BackupInfo, io.Writer) error); ok {
		r0 = rf(info, w)
	} else {
		r0 = ret.Error(0)
	}

	return r0
}
1212053
func (p *Policy) Backup(ctx context.Context, storage logical.Storage) (out string, retErr error) {
	if !p.Exportable {
		return "", fmt.Errorf("exporting is disallowed on the policy")
	}

	if !p.AllowPlaintextBackup {
		return "", fmt.Errorf("plaintext backup is disallowed on the policy")
	}

	priorBackupInfo := p.BackupInfo

	defer func() {
		if retErr != nil {
			p.BackupInfo = priorBackupInfo
		}
	}()

	// Create a record of this backup operation in the policy
	p.BackupInfo = &BackupInfo{
		Time:    time.Now(),
		Version: p.LatestVersion,
	}
	err := p.Persist(ctx, storage)
	if err != nil {
		return "", errwrap.Wrapf("failed to persist policy with backup info: {{err}}", err)
	}

	// Load the archive only after persisting the policy as the archive can get
	// adjusted while persisting the policy
	archivedKeys, err := p.LoadArchive(ctx, storage)
	if err != nil {
		return "", err
	}

	keyData := &KeyData{
		Policy:       p,
		ArchivedKeys: archivedKeys,
	}

	encodedBackup, err := jsonutil.EncodeJSON(keyData)
	if err != nil {
		return "", err
	}

	return base64.StdEncoding.EncodeToString(encodedBackup), nil
}
428894
func (e *FwdEdge) Back(c context.Context) (*BackDepGroup, *BackDep) {
	bdg := &BackDepGroup{Dependee: *e.To}
	return bdg, &BackDep{
		DependeeGroup: ds.KeyForObj(c, bdg),
		Depender:      *e.From,
	}
}
994128
func (bh *GCSBackupHandle) EndBackup(ctx context.Context) error {
	if bh.readOnly {
		return fmt.Errorf("EndBackup cannot be called on read-only backup")
	}
	return nil
}