// Backup provides a mock function with given fields: _a0, _a1
11218
func (_m *API) Backup(_a0 string, _a1 []string, _a2 bool) (string, error) {
	ret := _m.Called(_a0, _a1, _a2)

	var r0 string
	if rf, ok := ret.Get(0).(func(string, []string, bool) string); ok {
		r0 = rf(_a0, _a1, _a2)
	} else {
		r0 = ret.Get(0).(string)
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(string, []string, bool) error); ok {
		r1 = rf(_a0, _a1, _a2)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
669438
func (s *backupBlobStorage) File(id string) (io.ReadCloser, error) {
	file, _, err := s.storeImpl.GetForBucket(s.modelUUID, s.path(id))
	return file, errors.Trace(err)
}
1102822
func (l *StringLexer) Backup() {
	l.pos -= l.width
	if l.width == 1 && l.pos >= 0 && l.inputLen() > l.pos {
		if l.input[l.pos] == '\n' {
			l.line--
		}
	}
}
573946
func (client *Client) Backup(ctx context.Context, tablet *topodatapb.Tablet, concurrency int, allowMaster bool) (logutil.EventStream, error) {
	cc, c, err := client.dial(tablet)
	if err != nil {
		return nil, err
	}

	stream, err := c.Backup(ctx, &tabletmanagerdatapb.BackupRequest{
		Concurrency: int64(concurrency),
		AllowMaster: bool(allowMaster),
	})
	if err != nil {
		cc.Close()
		return nil, err
	}
	return &backupStreamAdapter{
		stream: stream,
		cc:     cc,
	}, nil
}
163558
func (c *CommandBase) dumpMetadata(ctx *cmd.Context, result *params.BackupsMetadataResult) {
	// TODO: (hml) 2018-04-26
	// fix how --quiet and --verbose are handled with backup/restore commands
	// should be ctx.Verbosef() here
	fmt.Fprintf(ctx.Stdout, "backup ID:       %q\n", result.ID)
	fmt.Fprintf(ctx.Stdout, "checksum:        %q\n", result.Checksum)
	fmt.Fprintf(ctx.Stdout, "checksum format: %q\n", result.ChecksumFormat)
	fmt.Fprintf(ctx.Stdout, "size (B):        %d\n", result.Size)
	fmt.Fprintf(ctx.Stdout, "stored:          %v\n", result.Stored)

	fmt.Fprintf(ctx.Stdout, "started:         %v\n", result.Started)
	fmt.Fprintf(ctx.Stdout, "finished:        %v\n", result.Finished)
	fmt.Fprintf(ctx.Stdout, "notes:           %q\n", result.Notes)

	fmt.Fprintf(ctx.Stdout, "model ID:        %q\n", result.Model)
	fmt.Fprintf(ctx.Stdout, "machine ID:      %q\n", result.Machine)
	fmt.Fprintf(ctx.Stdout, "created on host: %q\n", result.Hostname)
	fmt.Fprintf(ctx.Stdout, "juju version:    %v\n", result.Version)
}
1251867
func (s *DeleteBackupOutput) SetBackup(v *Backup) *DeleteBackupOutput {
	s.Backup = v
	return s
}
826046
func (b *BackupEngine) Close() {
	C.rocksdb_backup_engine_close(b.c)
	b.c = nil
}
231523
func (context *OpsManager) Backup() (err error) {
	if err = context.saveDeployments(); err == nil {
		err = context.saveInstallation()
	}
	return
}
828906
func (be *BuiltinBackupEngine) backupFiles(ctx context.Context, cnf *Mycnf, mysqld MysqlDaemon, logger logutil.Logger, bh backupstorage.BackupHandle, replicationPosition mysql.Position, backupConcurrency int, hookExtraEnv map[string]string) (err error) {
	// Get the files to backup.
	fes, err := findFilesToBackup(cnf)
	if err != nil {
		return vterrors.Wrap(err, "can't find files to backup")
	}
	logger.Infof("found %v files to backup", len(fes))

	// Backup with the provided concurrency.
	sema := sync2.NewSemaphore(backupConcurrency, 0)
	rec := concurrency.AllErrorRecorder{}
	wg := sync.WaitGroup{}
	for i := range fes {
		wg.Add(1)
		go func(i int) {
			defer wg.Done()

			// Wait until we are ready to go, skip if we already
			// encountered an error.
			sema.Acquire()
			defer sema.Release()
			if rec.HasErrors() {
				return
			}

			// Backup the individual file.
			name := fmt.Sprintf("%v", i)
			rec.RecordError(be.backupFile(ctx, cnf, mysqld, logger, bh, &fes[i], name, hookExtraEnv))
		}(i)
	}

	wg.Wait()
	if rec.HasErrors() {
		return rec.Error()
	}

	// open the MANIFEST
	wc, err := bh.AddFile(ctx, backupManifest, 0)
	if err != nil {
		return vterrors.Wrapf(err, "cannot add %v to backup", backupManifest)
	}
	defer func() {
		if closeErr := wc.Close(); err == nil {
			err = closeErr
		}
	}()

	// JSON-encode and write the MANIFEST
	bm := &builtinBackupManifest{
		FileEntries:   fes,
		Position:      replicationPosition,
		TransformHook: *backupStorageHook,
		SkipCompress:  !*backupStorageCompress,
	}
	data, err := json.MarshalIndent(bm, "", "  ")
	if err != nil {
		return vterrors.Wrapf(err, "cannot JSON encode %v", backupManifest)
	}
	if _, err := wc.Write([]byte(data)); err != nil {
		return vterrors.Wrapf(err, "cannot write %v", backupManifest)
	}

	return nil
}
78472
func (p *Process) Restore(r io.Reader) (*BackupInfo, error) {
	if err := p.writeConfig(configData{}); err != nil {
		return nil, err
	}
	if err := p.unpackXbstream(r); err != nil {
		return nil, err
	}
	backupInfo, err := p.extractBackupInfo()
	if err != nil {
		return nil, err
	}
	if err := p.restoreApplyLog(); err != nil {
		return nil, err
	}
	return backupInfo, nil
}
658922
func (f *Facade) EstimateBackup(ctx datastore.Context, request dao.BackupRequest, estimate *dao.BackupEstimate) error {
	defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.EstimateBackup"))

	stime := time.Now()
	plog.WithField("request", request).Debug("Started backup estimate")

	options := config.GetOptions()

	// Do not DFSLock here, ControlPlaneDao does that

	estimate.BackupPath = request.Dirpath
	// Get Filesystem free space
	estimate.AvailableBytes = volume.FilesystemBytesAvailable(request.Dirpath)
	estimate.AvailableString = humanize.Bytes(estimate.AvailableBytes)

	plog.WithFields(logrus.Fields{
		"dirpath":  request.Dirpath,
		"estimate": estimate,
	}).Debug("Checked FilestystemSpaceAvailable")

	// Estimate bytes to backup from filesystem
	_, images, err := f.GetServiceTemplatesAndImages(ctx)
	if err != nil {
		plog.WithError(err).Debug("Could not get service templates and images")
		return err
	}

	plog.WithField("elapsed", time.Since(stime)).Debug("Loaded templates and their images")

	tenants, err := f.GetTenantIDs(ctx)
	if err != nil {
		plog.WithError(err).Debug("Could not get tenants")
		return err
	}

	volumesPath := options.VolumesPath
	var FilesystemBytesRequired, DockerBytesRequired uint64

	for _, tenant := range tenants {
		tenantPath := filepath.Join(volumesPath, tenant)
		tenantLogger := plog.WithFields(logrus.Fields{
			"tenant":     tenant,
			"tenantPath": tenantPath,
		})
		tpsize, err := f.dfs.DfPath(tenantPath, request.Excludes)
		if err != nil {
			tenantLogger.WithError(err).Info("Could not get size for path.")
		}

		FilesystemBytesRequired += tpsize
	}
	plog.WithField("elapsed", time.Since(stime)).Debugf("Estimated filesystem backup size at %d", FilesystemBytesRequired)

	// Estimate Docker image bytes to backup
	size, err := f.dfs.EstimateImagePullSize(images)
	if err != nil {
		plog.WithError(err).Info("Could not get size for images.")
		return err
	}
	plog.WithField("elapsed", time.Since(stime)).Debugf("Estimated Docker pull size at %d", size)
	DockerBytesRequired = size

	MinOverheadBytes, err := humanize.ParseBytes(options.BackupMinOverhead)
	if err != nil {
		plog.WithError(err).Info("Unable to get MinOverheadBytes")
		MinOverheadBytes = 1 * 1000 * 1000 * 1000 // default to 1G
	}
	CompressionEst := options.BackupEstimatedCompression
	TotalBytesRequired := FilesystemBytesRequired + DockerBytesRequired
	AdjustedBytesRequired := uint64(float64(TotalBytesRequired)/CompressionEst+0.5) + MinOverheadBytes
	estimate.EstimatedBytes = AdjustedBytesRequired
	estimate.EstimatedString = humanize.Bytes(AdjustedBytesRequired)
	estimate.AllowBackup = estimate.EstimatedBytes < estimate.AvailableBytes

	plog.WithFields(logrus.Fields{
		"duration":                   time.Since(stime),
		"filesystembytes":            FilesystemBytesRequired,
		"dockerbytes":                DockerBytesRequired,
		"BackupEstimatedCompression": CompressionEst,
		"BackupMinOverhead":          options.BackupMinOverhead,
		"estimate":                   estimate,
	}).Debug("Completed backup estimate")
	return nil
}
1160908
func (l *lexer) backup() {
	l.pos -= l.width
	l.col, l.line = l.lastCol, l.lastLine
}
794399
func (*backups) Restore(_ string, _ RestoreArgs) (names.Tag, error) {
	return nil, errors.Errorf("backups supported only on Linux")
}
1341834
func Dump(c *cli.Context) {
	hostsfile := AlwaysLoadHostFile(c)
	jsonbytes, err := hostsfile.Hosts.Dump()
	if err != nil {
		MaybeError(c, err.Error())
	}
	fmt.Println(fmt.Sprintf("%s", jsonbytes))
}
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
}
1300153
func (bs *S3BackupStorage) StartBackup(ctx context.Context, dir, name string) (backupstorage.BackupHandle, error) {
	log.Infof("StartBackup: [s3] dir: %v, name: %v, bucket: %v", dir, name, *bucket)
	c, err := bs.client()
	if err != nil {
		return nil, err
	}

	return &S3BackupHandle{
		client:   c,
		bs:       bs,
		dir:      dir,
		name:     name,
		readOnly: false,
	}, nil
}
39169
func (t *Tree) backup2(t1 item) {
	t.token[1] = t1
	t.peekCount = 2
}