@@ -42,7 +42,6 @@ def backup_database(output_file: str, force: bool = False, backup_to_workers: in
4242
4343 unit = get_unit_name ()
4444 experiment = UNIVERSAL_EXPERIMENT
45- dump_output_file = output_file + ".txt"
4645
4746 with long_running_managed_lifecycle (unit , experiment , "backup_database" ) as mj :
4847 logger = create_logger (
@@ -69,20 +68,13 @@ def backup_database(output_file: str, force: bool = False, backup_to_workers: in
6968 con .backup (bck , pages = page_size )
7069
7170 bck .close ()
72- logger .info (f"Completed backup of database to { output_file } ." )
73-
74- # let's also dump the data for sharing to other workers as an additional backup
75- with open (dump_output_file , "w" ) as f :
76- for line in con .iterdump ():
77- f .write ("%s\n " % line )
78-
79- logger .info (f"Completed dumping of database to { dump_output_file } ." )
80-
8171 con .close ()
8272
8373 with local_persistent_storage ("database_backups" ) as cache :
8474 cache ["latest_backup_timestamp" ] = current_time
8575
76+ logger .info ("Completed backup of database." )
77+
8678 # back up to workers, if available
8779 backups_complete = 0
8880 try :
@@ -94,30 +86,29 @@ def backup_database(output_file: str, force: bool = False, backup_to_workers: in
9486 while (backups_complete < backup_to_workers ) and (len (available_workers ) > 0 ):
9587 backup_unit = available_workers .pop ()
9688 if backup_unit == unit :
97- # skip self
9889 continue
9990
100- logger .debug (f"Attempting sending database dump to { backup_unit } ." )
91+ logger .debug (f"Attempting backing up database to { backup_unit } ." )
10192 try :
10293 rsync (
10394 "-hz" ,
10495 "--partial" ,
10596 "--inplace" ,
106- dump_output_file ,
107- f"{ resolve_to_address (backup_unit )} :{ dump_output_file } " ,
97+ output_file ,
98+ f"{ resolve_to_address (backup_unit )} :{ output_file } " ,
10899 )
109100 except RsyncError :
110101 logger .debug (
111- f"Unable to send db dump to { backup_unit } . Is it online?" ,
102+ f"Unable to backup database to { backup_unit } . Is it online?" ,
112103 exc_info = True ,
113104 )
114- logger .warning (f"Unable to send db dump to { backup_unit } . Is it online?" )
105+ logger .warning (f"Unable to backup database to { backup_unit } . Is it online?" )
115106 else :
116- logger .debug (f"Sent db dump to { backup_unit } :{ dump_output_file } ." )
107+ logger .debug (f"Backed up database to { backup_unit } :{ output_file } ." )
117108 backups_complete += 1
118109
119110 with local_persistent_storage ("database_backups" ) as cache :
120- cache [f"latest_dump_in_ { backup_unit } _timestamp" ] = current_time
111+ cache [f"latest_backup_in_ { backup_unit } _timestamp" ] = current_time
121112
122113 return
123114
0 commit comments