diff --git a/CHANGELOG.md b/CHANGELOG.md index 0aece1e..1e7080f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project follows [Semantic Versioning](https://semver.org/). - Fail standby setup before mutation when required credentials do not resolve. - Scope standby rollback to the requested host and keep existing cluster nodes intact. - Preserve pgBackRest recovery options as one shell-safe argument during remote restore. +- Preserve the complete pgBackRest command as the single `bash -lc` command string. - Run component rollback in local Ruby context instead of an SSHKit backend scope. ## 0.9.6 - 2026-08-20 diff --git a/lib/active_postgres/components/repmgr.rb b/lib/active_postgres/components/repmgr.rb index 93d038e..b3f7469 100644 --- a/lib/active_postgres/components/repmgr.rb +++ b/lib/active_postgres/components/repmgr.rb @@ -921,7 +921,7 @@ def pgbackrest_restore_arguments(primary_conninfo) [ :sudo, '-u', config.postgres_user, - :bash, '-lc', command + :bash, '-lc', Shellwords.escape(command) ] end diff --git a/test/repmgr_test.rb b/test/repmgr_test.rb index a2a0795..5a2480d 100644 --- a/test/repmgr_test.rb +++ b/test/repmgr_test.rb @@ -54,10 +54,12 @@ def test_pgbackrest_restore_uses_standby_mode_and_primary_conninfo arguments = @component.send(:pgbackrest_restore_arguments, conninfo) assert_equal [:sudo, '-u', 'postgres', :bash, '-lc'], arguments.first(5) + transported_command = Shellwords.split(arguments.fetch(5)) + assert_equal 1, transported_command.length assert_equal [ 'pgbackrest', '--stanza=main', '--type=standby', "--recovery-option=primary_conninfo=#{conninfo}", 'restore' - ], Shellwords.split(arguments.fetch(5)) + ], Shellwords.split(transported_command.fetch(0)) end def test_manual_failover_policy_disables_repmgrd