@@ -707,7 +707,7 @@ def check_ptrack_clean(self, idx_dict, size):
707
707
)
708
708
)
709
709
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 ):
711
711
if not self .probackup_old_path and old_binary :
712
712
print ('PGPROBACKUPBIN_OLD is not set' )
713
713
exit (1 )
@@ -717,6 +717,9 @@ def run_pb(self, command, asynchronous=False, gdb=False, old_binary=False, retur
717
717
else :
718
718
binary_path = self .probackup_path
719
719
720
+ if not env :
721
+ env = self .test_env
722
+
720
723
try :
721
724
self .cmd = [' ' .join (map (str , [binary_path ] + command ))]
722
725
if self .verbose :
@@ -728,13 +731,13 @@ def run_pb(self, command, asynchronous=False, gdb=False, old_binary=False, retur
728
731
self .cmd ,
729
732
stdout = subprocess .PIPE ,
730
733
stderr = subprocess .PIPE ,
731
- env = self . test_env
734
+ env = env
732
735
)
733
736
else :
734
737
self .output = subprocess .check_output (
735
738
[binary_path ] + command ,
736
739
stderr = subprocess .STDOUT ,
737
- env = self . test_env
740
+ env = env
738
741
).decode ('utf-8' )
739
742
if command [0 ] == 'backup' and return_id :
740
743
# return backup ID
@@ -845,7 +848,8 @@ def backup_node(
845
848
self , backup_dir , instance , node , data_dir = False ,
846
849
backup_type = 'full' , datname = False , options = [],
847
850
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
849
853
):
850
854
if not node and not data_dir :
851
855
print ('You must provide ether node or data_dir for backup' )
@@ -878,7 +882,7 @@ def backup_node(
878
882
if not old_binary :
879
883
cmd_list += ['--no-sync' ]
880
884
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 )
882
886
883
887
def checkdb_node (
884
888
self , backup_dir = False , instance = False , data_dir = False ,
@@ -942,7 +946,8 @@ def restore_node(
942
946
943
947
def show_pb (
944
948
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
946
951
):
947
952
948
953
backup_list = []
@@ -963,7 +968,7 @@ def show_pb(
963
968
964
969
if as_text :
965
970
# 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 )
967
972
968
973
# get show result as list of lines
969
974
if as_json :
@@ -988,7 +993,7 @@ def show_pb(
988
993
return backup_list
989
994
else :
990
995
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 ()
992
997
if instance is not None and backup_id is None :
993
998
# cut header(ID, Mode, etc) from show as single string
994
999
header = show_splitted [1 :2 ][0 ]
0 commit comments