3131from libvirtnbdbackup .exceptions import RestoreError
3232
3333
34- def restore (args : Namespace , vmConfig : str , virtClient : virt .client ) -> None :
34+ def restore (
35+ args : Namespace , vmConfig : str , virtClient : virt .client , restConfig : bytes
36+ ) -> bytes :
3537 """Notice user if backed up vm had loader / nvram"""
3638 config = vmconfig .read (vmConfig )
3739 info = virtClient .getDomainInfo (config )
40+ restored_files = {}
3841
3942 for setting , val in info .items ():
4043 f = lib .getLatest (args .input , f"*{ os .path .basename (val )} *" , - 1 )
4144 if args .restore_root is not None :
4245 _ , _ , val_as_relative = os .path .splitroot (val )
4346 val = os .path .join (args .restore_root , val_as_relative )
47+ restored_files [setting ] = os .path .abspath (val )
4448 if lib .exists (args , val ):
4549 logging .info (
4650 "File [%s]: for boot option [%s] already exists, skipping." ,
@@ -53,6 +57,10 @@ def restore(args: Namespace, vmConfig: str, virtClient: virt.client) -> None:
5357 "Restoring configured file [%s] for boot option [%s]" , val , setting
5458 )
5559 lib .copy (args , f [0 ], val )
60+ if restConfig != b"" and args .adjust_config is True :
61+ return vmconfig .apply_paths (restConfig , restored_files )
62+ else :
63+ return restConfig
5664
5765
5866def verify (args : Namespace , dataFiles : List [str ]) -> bool :
0 commit comments