diff --git a/definitions/procedures/backup/offline/candlepin_db.rb b/definitions/procedures/backup/offline/candlepin_db.rb index f00a6411e..5d2c94329 100644 --- a/definitions/procedures/backup/offline/candlepin_db.rb +++ b/definitions/procedures/backup/offline/candlepin_db.rb @@ -36,7 +36,8 @@ def local_backup pg_backup_file, :listed_incremental => File.join(@backup_dir, '.postgres.snar'), :volume_size => @tar_volume_size, - :data_dir => pg_data_dir + :data_dir => pg_data_dir, + :restore_dir => feature(:candlepin_database).data_dir ) end end diff --git a/definitions/procedures/backup/offline/foreman_db.rb b/definitions/procedures/backup/offline/foreman_db.rb index cd73c6465..2566077a5 100644 --- a/definitions/procedures/backup/offline/foreman_db.rb +++ b/definitions/procedures/backup/offline/foreman_db.rb @@ -39,11 +39,13 @@ def local_backup end def do_backup(pg_dir, cmd) + restore_dir = el? ? feature(:foreman_database).data_dir : pg_dir feature(:foreman_database).backup_local( pg_backup_file, :listed_incremental => File.join(@backup_dir, '.postgres.snar'), :volume_size => @tar_volume_size, :data_dir => pg_dir, + :restore_dir => restore_dir, :command => cmd ) end diff --git a/definitions/procedures/backup/offline/pulpcore_db.rb b/definitions/procedures/backup/offline/pulpcore_db.rb index 5aba2efc1..94a79a784 100644 --- a/definitions/procedures/backup/offline/pulpcore_db.rb +++ b/definitions/procedures/backup/offline/pulpcore_db.rb @@ -36,7 +36,8 @@ def local_backup pg_backup_file, :listed_incremental => File.join(@backup_dir, '.postgres.snar'), :volume_size => @tar_volume_size, - :data_dir => pg_data_dir + :data_dir => pg_data_dir, + :restore_dir => feature(:pulpcore_database).data_dir ) end end diff --git a/lib/foreman_maintain/concerns/base_database.rb b/lib/foreman_maintain/concerns/base_database.rb index 1fea0d59f..33c4446f3 100644 --- a/lib/foreman_maintain/concerns/base_database.rb +++ b/lib/foreman_maintain/concerns/base_database.rb @@ -101,13 +101,14 @@ def restore_dump(file, localdb, config = configuration) def backup_local(backup_file, extra_tar_options = {}) dir = extra_tar_options.fetch(:data_dir, data_dir) + restore_dir = extra_tar_options.fetch(:restore_dir, data_dir) command = extra_tar_options.fetch(:command, 'create') FileUtils.cd(dir) do tar_options = { :archive => backup_file, :command => command, - :transform => "s,^,#{dir[1..]},S", + :transform => "s,^,#{restore_dir[1..]},S", :files => '*', }.merge(extra_tar_options) feature(:tar).run(tar_options)