diff --git a/go/vt/mysqlctl/xtrabackupengine.go b/go/vt/mysqlctl/xtrabackupengine.go index e895ca4d96b..b99bdd17cf1 100644 --- a/go/vt/mysqlctl/xtrabackupengine.go +++ b/go/vt/mysqlctl/xtrabackupengine.go @@ -44,8 +44,7 @@ import ( // it implements the BackupEngine interface and contains all the logic // required to implement a backup/restore by invoking xtrabackup with // the appropriate parameters -type XtrabackupEngine struct { -} +type XtrabackupEngine struct{} var ( // path where backup engine program is located @@ -156,7 +155,6 @@ func closeFile(wc io.WriteCloser, fileName string, logger logutil.Logger, finalE // ExecuteBackup returns a boolean that indicates if the backup is usable, // and an overall error. func (be *XtrabackupEngine) ExecuteBackup(ctx context.Context, params BackupParams, bh backupstorage.BackupHandle) (complete bool, finalErr error) { - if xtrabackupUser == "" { return false, vterrors.New(vtrpc.Code_INVALID_ARGUMENT, "xtrabackupUser must be specified.") } @@ -248,7 +246,8 @@ func (be *XtrabackupEngine) backupFiles( flavor string, ) (replicationPosition mysql.Position, finalErr error) { backupProgram := path.Join(xtrabackupEnginePath, xtrabackupBinaryName) - flagsToExec := []string{"--defaults-file=" + params.Cnf.Path, + flagsToExec := []string{ + "--defaults-file=" + params.Cnf.Path, "--backup", "--socket=" + params.Cnf.SocketFile, "--slave-info", @@ -414,7 +413,6 @@ func (be *XtrabackupEngine) backupFiles( // ExecuteRestore restores from a backup. Any error is returned. func (be *XtrabackupEngine) ExecuteRestore(ctx context.Context, params RestoreParams, bh backupstorage.BackupHandle) (*BackupManifest, error) { - var bm xtraBackupManifest if err := getBackupManifestInto(ctx, bh, &bm); err != nil { @@ -477,7 +475,8 @@ func (be *XtrabackupEngine) restoreFromBackup(ctx context.Context, cnf *Mycnf, b logger.Infof("Restore: Preparing the extracted files") // prepare the backup restoreProgram := path.Join(xtrabackupEnginePath, xtrabackupBinaryName) - flagsToExec := []string{"--defaults-file=" + cnf.Path, + flagsToExec := []string{ + "--defaults-file=" + cnf.Path, "--prepare", "--target-dir=" + tempDir, } @@ -512,7 +511,8 @@ func (be *XtrabackupEngine) restoreFromBackup(ctx context.Context, cnf *Mycnf, b // then move-back logger.Infof("Restore: Move extracted and prepared files to final locations") - flagsToExec = []string{"--defaults-file=" + cnf.Path, + flagsToExec = []string{ + "--defaults-file=" + cnf.Path, "--move-back", "--target-dir=" + tempDir, } @@ -579,7 +579,7 @@ func (be *XtrabackupEngine) extractFiles(ctx context.Context, logger logutil.Log // Create the decompressor if needed. if compressed { var decompressor io.ReadCloser - var deCompressionEngine = bm.CompressionEngine + deCompressionEngine := bm.CompressionEngine if deCompressionEngine == "" { // For backward compatibility. Incase if Manifest is from N-1 binary // then we assign the default value of compressionEngine. diff --git a/go/vt/mysqlctl/xtrabackupengine_test.go b/go/vt/mysqlctl/xtrabackupengine_test.go index 7b1fdf86797..3d81d269608 100644 --- a/go/vt/mysqlctl/xtrabackupengine_test.go +++ b/go/vt/mysqlctl/xtrabackupengine_test.go @@ -25,7 +25,6 @@ import ( "testing" "github.com/stretchr/testify/assert" - "vitess.io/vitess/go/vt/logutil" )