@@ -658,6 +658,56 @@ async def test_backup_to_multiple_locations(
658658 assert coresys .backups .get (slug ).location is None
659659
660660
661+ @pytest .mark .usefixtures ("path_extern" , "tmp_supervisor_data" )
662+ @pytest .mark .parametrize (
663+ ("backup_type" , "inputs" ), [("full" , {}), ("partial" , {"folders" : ["ssl" ]})]
664+ )
665+ async def test_backup_to_multiple_locations_error_on_copy (
666+ api_client : TestClient ,
667+ coresys : CoreSys ,
668+ backup_type : str ,
669+ inputs : dict [str , Any ],
670+ ):
671+ """Test making a backup to multiple locations that fails during copy stage."""
672+ await coresys .core .set_state (CoreState .RUNNING )
673+ coresys .hardware .disk .get_disk_free_space = lambda x : 5000
674+
675+ with patch ("supervisor.backups.manager.shutil.copy" , side_effect = OSError ):
676+ resp = await api_client .post (
677+ f"/backups/new/{ backup_type } " ,
678+ json = {
679+ "name" : "Multiple locations test" ,
680+ "location" : [None , ".cloud_backup" ],
681+ }
682+ | inputs ,
683+ )
684+ assert resp .status == 200
685+ result = await resp .json ()
686+ assert result ["result" ] == "ok"
687+ slug = result ["data" ]["slug" ]
688+
689+ orig_backup = coresys .config .path_backup / f"{ slug } .tar"
690+ assert await coresys .run_in_executor (orig_backup .exists )
691+ assert coresys .backups .get (slug ).all_locations == {
692+ None : {"path" : orig_backup , "protected" : False , "size_bytes" : 10240 },
693+ }
694+ assert coresys .backups .get (slug ).location is None
695+
696+ resp = await api_client .get ("/jobs/info" )
697+ assert resp .status == 200
698+ result = await resp .json ()
699+ assert result ["data" ]["jobs" ][0 ]["name" ] == f"backup_manager_{ backup_type } _backup"
700+ assert result ["data" ]["jobs" ][0 ]["reference" ] == slug
701+ assert result ["data" ]["jobs" ][0 ]["done" ] is True
702+ assert result ["data" ]["jobs" ][0 ]["errors" ] == [
703+ {
704+ "type" : "BackupError" ,
705+ "message" : "Could not copy backup to .cloud_backup due to: " ,
706+ "stage" : "copy_additional_locations" ,
707+ }
708+ ]
709+
710+
661711@pytest .mark .parametrize (
662712 ("backup_type" , "inputs" ), [("full" , {}), ("partial" , {"folders" : ["ssl" ]})]
663713)
0 commit comments