@@ -707,7 +707,7 @@ def check_ptrack_clean(self, idx_dict, size):
707707 )
708708 )
709709
710- def run_pb (self , command , asynchronous = False , gdb = False , old_binary = False , return_id = True ):
710+ def run_pb (self , command , asynchronous = False , gdb = False , old_binary = False , return_id = True , env = None ):
711711 if not self .probackup_old_path and old_binary :
712712 print ('PGPROBACKUPBIN_OLD is not set' )
713713 exit (1 )
@@ -717,6 +717,9 @@ def run_pb(self, command, asynchronous=False, gdb=False, old_binary=False, retur
717717 else :
718718 binary_path = self .probackup_path
719719
720+ if not env :
721+ env = self .test_env
722+
720723 try :
721724 self .cmd = [' ' .join (map (str , [binary_path ] + command ))]
722725 if self .verbose :
@@ -728,13 +731,13 @@ def run_pb(self, command, asynchronous=False, gdb=False, old_binary=False, retur
728731 self .cmd ,
729732 stdout = subprocess .PIPE ,
730733 stderr = subprocess .PIPE ,
731- env = self . test_env
734+ env = env
732735 )
733736 else :
734737 self .output = subprocess .check_output (
735738 [binary_path ] + command ,
736739 stderr = subprocess .STDOUT ,
737- env = self . test_env
740+ env = env
738741 ).decode ('utf-8' )
739742 if command [0 ] == 'backup' and return_id :
740743 # return backup ID
@@ -845,7 +848,8 @@ def backup_node(
845848 self , backup_dir , instance , node , data_dir = False ,
846849 backup_type = 'full' , datname = False , options = [],
847850 asynchronous = False , gdb = False ,
848- old_binary = False , return_id = True , no_remote = False
851+ old_binary = False , return_id = True , no_remote = False ,
852+ env = None
849853 ):
850854 if not node and not data_dir :
851855 print ('You must provide ether node or data_dir for backup' )
@@ -878,7 +882,7 @@ def backup_node(
878882 if not old_binary :
879883 cmd_list += ['--no-sync' ]
880884
881- return self .run_pb (cmd_list + options , asynchronous , gdb , old_binary , return_id )
885+ return self .run_pb (cmd_list + options , asynchronous , gdb , old_binary , return_id , env = env )
882886
883887 def checkdb_node (
884888 self , backup_dir = False , instance = False , data_dir = False ,
@@ -942,7 +946,8 @@ def restore_node(
942946
943947 def show_pb (
944948 self , backup_dir , instance = None , backup_id = None ,
945- options = [], as_text = False , as_json = True , old_binary = False
949+ options = [], as_text = False , as_json = True , old_binary = False ,
950+ env = None
946951 ):
947952
948953 backup_list = []
@@ -963,7 +968,7 @@ def show_pb(
963968
964969 if as_text :
965970 # You should print it when calling as_text=true
966- return self .run_pb (cmd_list + options , old_binary = old_binary )
971+ return self .run_pb (cmd_list + options , old_binary = old_binary , env = env )
967972
968973 # get show result as list of lines
969974 if as_json :
@@ -988,7 +993,7 @@ def show_pb(
988993 return backup_list
989994 else :
990995 show_splitted = self .run_pb (
991- cmd_list + options , old_binary = old_binary ).splitlines ()
996+ cmd_list + options , old_binary = old_binary , env = env ).splitlines ()
992997 if instance is not None and backup_id is None :
993998 # cut header(ID, Mode, etc) from show as single string
994999 header = show_splitted [1 :2 ][0 ]
0 commit comments