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
7 changes: 7 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 @@ -262,6 +263,8 @@ func (bm *BackupManager) performBackup(backup *v1alpha1.Backup, db *sql.DB) erro
Message: backupErr.Error(),
})
errs = append(errs, uerr)
// just delete backupFullPath since it will never be used except for debug
Copy link
Contributor

Choose a reason for hiding this comment

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

If it's useful for debug, can we keep it just in case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed in df73f02

os.RemoveAll(backupFullPath)
return errorutils.NewAggregate(errs)
}
klog.Infof("dump cluster %s data to %s success", bm, backupFullPath)
Expand All @@ -282,6 +285,8 @@ func (bm *BackupManager) performBackup(backup *v1alpha1.Backup, db *sql.DB) erro
return errorutils.NewAggregate(errs)
}
klog.Infof("archive cluster %s backup data %s success", bm, archiveBackupPath)
// archive succeed, origin dir can be deleted safely
Copy link
Contributor

Choose a reason for hiding this comment

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

getCommitTsFromMetadata in L305 will fail.

os.RemoveAll(backupFullPath)

opts := util.GetOptions(backup.Spec.StorageProvider)
size, err := getBackupSize(archiveBackupPath, opts)
Expand Down Expand Up @@ -330,6 +335,8 @@ func (bm *BackupManager) performBackup(backup *v1alpha1.Backup, db *sql.DB) erro
return errorutils.NewAggregate(errs)
}
klog.Infof("backup cluster %s data to %s success", bm, bm.StorageType)
// backup to remote succeed, archive can be deleted now
os.RemoveAll(archiveBackupPath)

finish := time.Now()

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 @@ -166,6 +167,8 @@ func (rm *RestoreManager) performRestore(restore *v1alpha1.Restore) error {
return errorutils.NewAggregate(errs)
}
klog.Infof("unarchive cluster %s backup %s data success", rm, restoreDataPath)
// unarchive succeed, origin archive can be deleted now
Copy link
Contributor

Choose a reason for hiding this comment

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

What about keeping the tar, it does not make much difference since we keep the unarchieved files.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed in df73f02

os.RemoveAll(restoreDataPath)

err = rm.loadTidbClusterData(unarchiveDataPath)
if err != nil {
Expand Down