File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -483,7 +483,8 @@ def run_prefect_db_backup():
483483 ts = datetime .now (timezone .utc ).strftime ("%Y-%m-%dT%H%M%SZ" )
484484 OUTDIR = Path .home () / "prefect-backups"
485485 OUTDIR .mkdir (parents = True , exist_ok = True )
486- db_backup = OUTDIR / f"prefect-{ ts } .sql"
486+ db_file_name = f"prefect-{ ts } .sql"
487+ db_backup = OUTDIR / db_file_name
487488
488489 cmd = ["bash" , bkpscript , str (db_backup )]
489490 result = subprocess .run (cmd , capture_output = True , text = True )
@@ -503,9 +504,14 @@ def run_prefect_db_backup():
503504 )
504505 # --- Copy to CANFAR ---
505506 print ("Copying the backup to CANFAR..." )
506- client = Client ()
507- client .copy (str (db_backup ), "arc:projects/CIRADA/polarimetry/software/prefect-backups" )
508- print ("Backup completed successfully" )
507+ try :
508+ client = Client ()
509+ VOS_FOLDER = "arc:projects/CIRADA/polarimetry/software/prefect-backups"
510+ remote_file = f"{ VOS_FOLDER } /{ db_file_name } "
511+ client .copy (str (db_backup ), remote_file )
512+ print ("Backup completed successfully" )
513+ except Exception as e :
514+ print (f"Failed to copy backup to CANFAR: { e } " )
509515
510516if __name__ == "__main__" :
511517 parser = argparse .ArgumentParser (
You can’t perform that action at this time.
0 commit comments