Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove temp data in pv for backup #2897

Merged
merged 12 commits into from
Jul 14, 2020
5 changes: 5 additions & 0 deletions cmd/backup-manager/app/export/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package export

import (
"database/sql"
"os"
"strings"
"time"

Expand Down Expand Up @@ -235,6 +236,9 @@ func (bm *BackupManager) performBackup(backup *v1alpha1.Backup, db *sql.DB) erro
}

backupFullPath, backupErr := bm.dumpTidbClusterData(backup)
if len(backupFullPath) > 0 {
defer os.RemoveAll(backupFullPath)
}
if oldTikvGCTimeDuration < tikvGCTimeDuration {
err = bm.SetTikvGCLifeTime(db, oldTikvGCTime)
if err != nil {
Expand Down Expand Up @@ -268,6 +272,7 @@ func (bm *BackupManager) performBackup(backup *v1alpha1.Backup, db *sql.DB) erro

// TODO: Concurrent get file size and upload backup data to speed up processing time
archiveBackupPath := backupFullPath + constants.DefaultArchiveExtention
defer os.RemoveAll(archiveBackupPath)
err = archiveBackupData(backupFullPath, archiveBackupPath)
if err != nil {
errs = append(errs, err)
Expand Down
3 changes: 3 additions & 0 deletions cmd/backup-manager/app/import/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package _import
import (
"database/sql"
"fmt"
"os"
"path/filepath"
"time"

Expand Down Expand Up @@ -152,7 +153,9 @@ func (rm *RestoreManager) performRestore(restore *v1alpha1.Restore) error {
klog.Infof("download cluster %s backup %s data success", rm, rm.BackupPath)

restoreDataDir := filepath.Dir(restoreDataPath)
defer os.RemoveAll(restoreDataPath)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest not removing data after restore.

unarchiveDataPath, err := unarchiveBackupData(restoreDataPath, restoreDataDir)
defer os.RemoveAll(unarchiveDataPath)
DanielZhangQD marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
errs = append(errs, err)
klog.Errorf("unarchive cluster %s backup %s data failed, err: %s", rm, restoreDataPath, err)
Expand Down