@@ -413,9 +413,9 @@ func (u *BackupService) Update(req dto.BackupOperate) error {
413413 if strings .HasSuffix (dirStr , "/" ) && dirStr != "/" {
414414 dirStr = dirStr [:strings .LastIndex (dirStr , "/" )]
415415 }
416- if err := copyDir (oldDir , dirStr ); err != nil {
416+ if err := changeLocalBackup (oldDir , dirStr ); err != nil {
417417 _ = backupRepo .Update (req .ID , map [string ]interface {}{"vars" : oldVars })
418- return err
418+ return fmt . Errorf ( "copy dir from %s to %s failed, err: %v" , oldDir , dirStr , err )
419419 }
420420 global .CONF .System .Backup = dirStr
421421 }
@@ -677,3 +677,44 @@ func (u *BackupService) Run() {
677677 }).Error
678678 global .LOG .Info ("Successfully refreshed OneDrive token." )
679679}
680+
681+ func changeLocalBackup (oldPath , newPath string ) error {
682+ fileOp := fileUtils .NewFileOp ()
683+ if fileOp .Stat (path .Join (oldPath , "app" )) {
684+ if err := fileOp .CopyDir (path .Join (oldPath , "app" ), newPath ); err != nil {
685+ return err
686+ }
687+ }
688+ if fileOp .Stat (path .Join (oldPath , "database" )) {
689+ if err := fileOp .CopyDir (path .Join (oldPath , "database" ), newPath ); err != nil {
690+ return err
691+ }
692+ }
693+ if fileOp .Stat (path .Join (oldPath , "directory" )) {
694+ if err := fileOp .CopyDir (path .Join (oldPath , "directory" ), newPath ); err != nil {
695+ return err
696+ }
697+ }
698+ if fileOp .Stat (path .Join (oldPath , "system_snapshot" )) {
699+ if err := fileOp .CopyDir (path .Join (oldPath , "system_snapshot" ), newPath ); err != nil {
700+ return err
701+ }
702+ }
703+ if fileOp .Stat (path .Join (oldPath , "website" )) {
704+ if err := fileOp .CopyDir (path .Join (oldPath , "website" ), newPath ); err != nil {
705+ return err
706+ }
707+ }
708+ if fileOp .Stat (path .Join (oldPath , "log" )) {
709+ if err := fileOp .CopyDir (path .Join (oldPath , "log" ), newPath ); err != nil {
710+ return err
711+ }
712+ }
713+ _ = fileOp .RmRf (path .Join (oldPath , "app" ))
714+ _ = fileOp .RmRf (path .Join (oldPath , "database" ))
715+ _ = fileOp .RmRf (path .Join (oldPath , "directory" ))
716+ _ = fileOp .RmRf (path .Join (oldPath , "system_snapshot" ))
717+ _ = fileOp .RmRf (path .Join (oldPath , "website" ))
718+ _ = fileOp .RmRf (path .Join (oldPath , "log" ))
719+ return nil
720+ }
0 commit comments