Skip to content

Commit

Permalink
Fixes #36480 - add restore_dir option to backup_local
Browse files Browse the repository at this point in the history
Without a restore_dir option, snapshot backups cannot be restored with "foreman-maintain restore".
  • Loading branch information
Martin Schlossarek authored and Martin Schlossarek committed Jun 6, 2023
1 parent ed1d230 commit 995f012
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion definitions/procedures/backup/offline/candlepin_db.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions definitions/procedures/backup/offline/foreman_db.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def do_backup(pg_dir, cmd)
:listed_incremental => File.join(@backup_dir, '.postgres.snar'),
:volume_size => @tar_volume_size,
:data_dir => pg_dir,
:restore_dir => feature(:foreman_database).data_dir,
:command => cmd
)
end
Expand Down
3 changes: 2 additions & 1 deletion definitions/procedures/backup/offline/pulpcore_db.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion lib/foreman_maintain/concerns/base_database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 995f012

Please sign in to comment.