@@ -25,6 +25,7 @@ import (
2525 "olares.com/backup-server/pkg/util/pointer"
2626 "olares.com/backup-server/pkg/watchers/notification"
2727 backupssdk "olares.com/backups-sdk"
28+ backupssdkconstants "olares.com/backups-sdk/pkg/constants"
2829 backupssdkoptions "olares.com/backups-sdk/pkg/options"
2930 backupssdkrestic "olares.com/backups-sdk/pkg/restic"
3031 backupssdkstorage "olares.com/backups-sdk/pkg/storage"
@@ -322,21 +323,16 @@ func (s *StorageBackup) checkDiskSize() error {
322323 return err
323324 }
324325
325- log .Infof ("Backup %s,%s, check disk free space: %s, path: %s" , backupName , snapshotId , usage .String (), target )
326-
327- if usage .UsedPercent > FreeLimit {
328- log .Errorf ("Backup %s,%s, disk usage has reached %.2f%%" , backupName , snapshotId , FreeLimit )
329- return fmt .Errorf ("Disk usage has reached %.2f%%. Please clean up disk space first." , FreeLimit )
330- }
326+ log .Infof ("Backup %s,%s, check disk free space: %s, path: %s, limit: %d" , backupName , snapshotId , usage .String (), target , backupssdkconstants .FreeSpaceLimit )
331327
332328 backupSize , err := util .DirSize (s .Params .Path )
333329 if err != nil {
334330 log .Errorf ("Backup %s,%s, get backup disk size error: %v, path: %s" , backupName , snapshotId , err , s .Params .Path )
335331 return fmt .Errorf ("get backup disk size error: %v, path: %s" , err , s .Params .Path )
336332 }
337333
338- requiredSpace := uint64 ( float64 ( backupSize ) * 1.05 )
339- if usage .Free < requiredSpace {
334+ requiredSpace := backupSize
335+ if usage .Free < ( requiredSpace + backupssdkconstants . FreeSpaceLimit ) {
340336 log .Errorf ("not enough free space on target disk, required: %s, available: %s, location: %s" , util .FormatBytes (requiredSpace ), util .FormatBytes (usage .Free ), s .Params .LocationInFileSystem )
341337 return fmt .Errorf ("Insufficient space on the target disk." )
342338 }
0 commit comments