@@ -73,6 +73,9 @@ def backup_old_directories(self):
7373 if not os .path .exists (BACKUP_DIR ):
7474 os .mkdir (BACKUP_DIR )
7575
76+ # move old backups to create space
77+ self ._move_old_backups_to_share ()
78+
7679 # Move the folders
7780 for path in DIRECTORIES_TO_BACKUP :
7881 if path in os .getcwd ():
@@ -83,7 +86,6 @@ def backup_old_directories(self):
8386 else :
8487 self ._backup_dir (path , ignore = IGNORE_PATTERNS .get (path ), copy = True )
8588
86- self ._move_old_backups_to_share ()
8789 else :
8890 self .prompt .prompt_and_raise_if_not_yes (
8991 f"Unable to find data directory '{ BACKUP_DATA_DIR } '. Please backup the current installation of IBEX "
@@ -222,21 +224,17 @@ def copy_function(src, dst):
222224 # ? Moving other backups to stage deleted could be a task on its own
223225 def _move_old_backups_to_share (self ):
224226 """
225- Move all but the newest backup to the shares.
227+ Move all backups to the shares. This should be
228+ run before the current installation is backed up
226229
227230 """
228231 current_backups = [
229232 os .path .join (BACKUP_DIR , d )
230233 for d in os .listdir (BACKUP_DIR )
231234 if os .path .isdir (os .path .join (BACKUP_DIR , d )) and d .startswith ("ibex_backup" )
232235 ]
233- if len (current_backups ) > 0 :
234- all_but_newest_backup = sorted (current_backups , key = os .path .getmtime )[:- 1 ]
235- backups_to_move = all_but_newest_backup
236- else :
237- backups_to_move = []
238236
239- for d in backups_to_move :
237+ for d in current_backups :
240238 backup = STAGE_DELETED + "\\ " + self ._get_machine_name () + "\\ " + os .path .basename (d )
241239 print (f"Moving backup { d } to { backup } " )
242240 self ._file_utils .move_dir (d , backup , self .prompt )
0 commit comments