@@ -329,47 +329,6 @@ main(int argc, char *argv[])
329329}
330330canonicalize_path (backup_path );
331331
332- /* Ensure that backup_path is an absolute path */
333- if (!is_absolute_path (backup_path ))
334- elog (ERROR ,"-B, --backup-path must be an absolute path" );
335-
336- /*
337- * We read options from command line, now we need to read them from
338- * configuration file since we got backup path and instance name.
339- * For some commands an instance option isn't required, see above.
340- */
341- if (instance_name )
342- {
343- char path [MAXPGPATH ];
344-
345- /* Read environment variables */
346- config_get_opt_env (instance_options );
347-
348- /* Read options from configuration file */
349- join_path_components (path ,backup_instance_path ,BACKUP_CATALOG_CONF_FILE );
350- config_read_opt (path ,instance_options ,ERROR , true);
351- }
352-
353- if (IsSshProtocol ()
354- && (backup_subcmd == BACKUP_CMD || backup_subcmd == ADD_INSTANCE_CMD || backup_subcmd == RESTORE_CMD ||
355- backup_subcmd == ARCHIVE_PUSH_CMD || backup_subcmd == ARCHIVE_GET_CMD ))
356- {
357- if (remote_agent ) {
358- if (backup_subcmd != BACKUP_CMD && backup_subcmd != ARCHIVE_PUSH_CMD ) {
359- fio_communicate (STDIN_FILENO ,STDOUT_FILENO );
360- return 0 ;
361- }
362- fio_redirect (STDIN_FILENO ,STDOUT_FILENO );
363- }else {
364- /* Execute remote probackup */
365- int status = remote_execute (argc ,argv ,backup_subcmd == BACKUP_CMD || backup_subcmd == ARCHIVE_PUSH_CMD );
366- if (status != 0 || backup_subcmd == ARCHIVE_PUSH_CMD )
367- {
368- return status ;
369- }
370- }
371- }
372-
373332if (!remote_agent )
374333{
375334/* Ensure that backup_path is a path to a directory */
@@ -378,6 +337,11 @@ main(int argc, char *argv[])
378337elog (ERROR ,"-B, --backup-path must be a path to directory" );
379338}
380339
340+ /* Ensure that backup_path is an absolute path */
341+ if (!is_absolute_path (backup_path ))
342+ elog (ERROR ,"-B, --backup-path must be an absolute path" );
343+
344+
381345/* Option --instance is required for all commands except init and show */
382346if (backup_subcmd != INIT_CMD && backup_subcmd != SHOW_CMD &&
383347backup_subcmd != VALIDATE_CMD )
@@ -409,9 +373,46 @@ main(int argc, char *argv[])
409373}
410374}
411375
376+ /*
377+ * We read options from command line, now we need to read them from
378+ * configuration file since we got backup path and instance name.
379+ * For some commands an instance option isn't required, see above.
380+ */
381+ if (instance_name && !remote_agent )
382+ {
383+ char path [MAXPGPATH ];
384+
385+ /* Read environment variables */
386+ config_get_opt_env (instance_options );
387+
388+ /* Read options from configuration file */
389+ join_path_components (path ,backup_instance_path ,BACKUP_CATALOG_CONF_FILE );
390+ config_read_opt (path ,instance_options ,ERROR , true);
391+ }
392+
412393/* Initialize logger */
413394init_logger (backup_path ,& instance_config .logger );
414395
396+ if (IsSshProtocol ()
397+ && (backup_subcmd == BACKUP_CMD || backup_subcmd == ADD_INSTANCE_CMD || backup_subcmd == RESTORE_CMD ||
398+ backup_subcmd == ARCHIVE_PUSH_CMD || backup_subcmd == ARCHIVE_GET_CMD ))
399+ {
400+ if (remote_agent ) {
401+ if (backup_subcmd != BACKUP_CMD && backup_subcmd != ARCHIVE_PUSH_CMD ) {
402+ fio_communicate (STDIN_FILENO ,STDOUT_FILENO );
403+ return 0 ;
404+ }
405+ fio_redirect (STDIN_FILENO ,STDOUT_FILENO );
406+ }else {
407+ /* Execute remote probackup */
408+ int status = remote_execute (argc ,argv ,backup_subcmd == BACKUP_CMD || backup_subcmd == ARCHIVE_PUSH_CMD );
409+ if (status != 0 || backup_subcmd == ARCHIVE_PUSH_CMD )
410+ {
411+ return status ;
412+ }
413+ }
414+ }
415+
415416/* command was initialized for a few commands */
416417if (command )
417418{