foreman_maintain 1.5.1 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -20
- data/definitions/checks/disk/available_space_candlepin.rb +1 -1
- data/definitions/checks/disk/available_space_postgresql13.rb +42 -0
- data/definitions/checks/foreman/check_corrupted_roles.rb +0 -3
- data/definitions/checks/foreman/validate_external_db_version.rb +1 -2
- data/definitions/features/foreman_proxy.rb +1 -5
- data/definitions/features/foreman_tasks.rb +2 -6
- data/definitions/features/installer.rb +0 -4
- data/definitions/features/pulpcore_database.rb +1 -1
- data/definitions/procedures/backup/offline/candlepin_db.rb +1 -6
- data/definitions/procedures/backup/offline/foreman_db.rb +1 -8
- data/definitions/procedures/backup/offline/pulpcore_db.rb +1 -6
- data/definitions/procedures/backup/pulp.rb +1 -10
- data/definitions/procedures/foreman/fix_corrupted_roles.rb +0 -3
- data/definitions/procedures/puppet/remove_puppet.rb +1 -2
- data/definitions/procedures/restore/installer_reset.rb +1 -17
- data/definitions/scenarios/backup.rb +5 -88
- data/definitions/scenarios/packages.rb +2 -2
- data/definitions/scenarios/puppet.rb +4 -6
- data/definitions/scenarios/restore.rb +1 -1
- data/definitions/scenarios/upgrade_to_capsule_6_16.rb +7 -4
- data/definitions/scenarios/upgrade_to_capsule_6_16_z.rb +6 -4
- data/definitions/scenarios/upgrade_to_foreman_nightly.rb +3 -3
- data/definitions/scenarios/upgrade_to_katello_nightly.rb +6 -4
- data/definitions/scenarios/upgrade_to_satellite_6_16.rb +7 -4
- data/definitions/scenarios/upgrade_to_satellite_6_16_z.rb +6 -4
- data/lib/foreman_maintain/cli/backup_command.rb +0 -27
- data/lib/foreman_maintain/cli.rb +2 -0
- data/lib/foreman_maintain/concerns/base_database.rb +0 -4
- data/lib/foreman_maintain/concerns/downstream.rb +0 -4
- data/lib/foreman_maintain/concerns/os_facts.rb +4 -0
- data/lib/foreman_maintain/concerns/system_helpers.rb +0 -12
- data/lib/foreman_maintain/version.rb +1 -1
- data/lib/foreman_maintain.rb +1 -1
- metadata +3 -15
- data/definitions/checks/disk/available_space_postgresql12.rb +0 -46
- data/definitions/procedures/backup/snapshot/clean_mount.rb +0 -24
- data/definitions/procedures/backup/snapshot/logical_volume_confirmation.rb +0 -56
- data/definitions/procedures/backup/snapshot/mount_base.rb +0 -27
- data/definitions/procedures/backup/snapshot/mount_candlepin_db.rb +0 -48
- data/definitions/procedures/backup/snapshot/mount_foreman_db.rb +0 -48
- data/definitions/procedures/backup/snapshot/mount_pulp.rb +0 -32
- data/definitions/procedures/backup/snapshot/mount_pulpcore_db.rb +0 -48
- data/definitions/procedures/backup/snapshot/prepare_mount.rb +0 -16
- data/definitions/procedures/backup/snapshot/snapshot_deprecation_message.rb +0 -14
- data/definitions/procedures/foreman/remove_duplicate_obsolete_roles.rb +0 -64
- data/definitions/procedures/installer/run_for_6_11.rb +0 -52
- data/definitions/procedures/installer/upgrade.rb +0 -12
@@ -47,20 +47,22 @@ module Scenarios::Katello_Nightly
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def set_context_mapping
|
50
|
-
context.map(:assumeyes, Procedures::Installer::
|
50
|
+
context.map(:assumeyes, Procedures::Installer::Run => :assumeyes)
|
51
51
|
end
|
52
52
|
|
53
53
|
def compose
|
54
54
|
add_step(Procedures::Repositories::Setup.new(:version => 'nightly'))
|
55
|
-
|
56
|
-
|
55
|
+
if el8?
|
56
|
+
modules_to_enable = ["katello:#{el_short_name}", "pulpcore:#{el_short_name}"]
|
57
|
+
add_step(Procedures::Packages::EnableModules.new(:module_names => modules_to_enable))
|
58
|
+
end
|
57
59
|
add_step(Procedures::Packages::Update.new(
|
58
60
|
:assumeyes => true,
|
59
61
|
:dnf_options => ['--downloadonly']
|
60
62
|
))
|
61
63
|
add_step(Procedures::Service::Stop.new)
|
62
64
|
add_step(Procedures::Packages::Update.new(:assumeyes => true, :clean_cache => false))
|
63
|
-
add_step_with_context(Procedures::Installer::
|
65
|
+
add_step_with_context(Procedures::Installer::Run)
|
64
66
|
end
|
65
67
|
end
|
66
68
|
|
@@ -27,6 +27,7 @@ module Scenarios::Satellite_6_16
|
|
27
27
|
def compose
|
28
28
|
add_steps(find_checks(:default))
|
29
29
|
add_steps(find_checks(:pre_upgrade))
|
30
|
+
add_step(Checks::Disk::AvailableSpacePostgresql13)
|
30
31
|
add_step(Checks::Repositories::Validate.new(:version => '6.16'))
|
31
32
|
end
|
32
33
|
end
|
@@ -39,8 +40,10 @@ module Scenarios::Satellite_6_16
|
|
39
40
|
|
40
41
|
def compose
|
41
42
|
add_step(Procedures::Repositories::Setup.new(:version => '6.16'))
|
42
|
-
|
43
|
-
|
43
|
+
if el8?
|
44
|
+
modules_to_enable = ["satellite:#{el_short_name}"]
|
45
|
+
add_step(Procedures::Packages::EnableModules.new(:module_names => modules_to_enable))
|
46
|
+
end
|
44
47
|
add_step(Procedures::Packages::Update.new(
|
45
48
|
:assumeyes => true,
|
46
49
|
:dnf_options => ['--downloadonly']
|
@@ -57,13 +60,13 @@ module Scenarios::Satellite_6_16
|
|
57
60
|
end
|
58
61
|
|
59
62
|
def set_context_mapping
|
60
|
-
context.map(:assumeyes, Procedures::Installer::
|
63
|
+
context.map(:assumeyes, Procedures::Installer::Run => :assumeyes)
|
61
64
|
end
|
62
65
|
|
63
66
|
def compose
|
64
67
|
add_step(Procedures::Service::Stop.new)
|
65
68
|
add_step(Procedures::Packages::Update.new(:assumeyes => true, :clean_cache => false))
|
66
|
-
add_step_with_context(Procedures::Installer::
|
69
|
+
add_step_with_context(Procedures::Installer::Run)
|
67
70
|
add_step(Procedures::Installer::UpgradeRakeTask)
|
68
71
|
end
|
69
72
|
end
|
@@ -39,8 +39,10 @@ module Scenarios::Satellite_6_16_z
|
|
39
39
|
|
40
40
|
def compose
|
41
41
|
add_step(Procedures::Repositories::Setup.new(:version => '6.16'))
|
42
|
-
|
43
|
-
|
42
|
+
if el8?
|
43
|
+
modules_to_enable = ["satellite:#{el_short_name}"]
|
44
|
+
add_step(Procedures::Packages::EnableModules.new(:module_names => modules_to_enable))
|
45
|
+
end
|
44
46
|
add_step(Procedures::Packages::Update.new(
|
45
47
|
:assumeyes => true,
|
46
48
|
:dnf_options => ['--downloadonly']
|
@@ -56,13 +58,13 @@ module Scenarios::Satellite_6_16_z
|
|
56
58
|
end
|
57
59
|
|
58
60
|
def set_context_mapping
|
59
|
-
context.map(:assumeyes, Procedures::Installer::
|
61
|
+
context.map(:assumeyes, Procedures::Installer::Run => :assumeyes)
|
60
62
|
end
|
61
63
|
|
62
64
|
def compose
|
63
65
|
add_step(Procedures::Service::Stop.new)
|
64
66
|
add_step(Procedures::Packages::Update.new(:assumeyes => true, :clean_cache => false))
|
65
|
-
add_step_with_context(Procedures::Installer::
|
67
|
+
add_step_with_context(Procedures::Installer::Run)
|
66
68
|
add_step(Procedures::Installer::UpgradeRakeTask)
|
67
69
|
end
|
68
70
|
end
|
@@ -127,36 +127,9 @@ module ForemanMaintain
|
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
130
|
-
class SnapshotBackupCommand < Base
|
131
|
-
include BackupCommon
|
132
|
-
interactive_option
|
133
|
-
common_backup_options
|
134
|
-
option '--include-db-dumps', :flag, 'Also dump full database schema before snapshot backup'
|
135
|
-
option ['-d', '--snapshot-mount-dir'], 'SNAPSHOT_MOUNT_DIR',
|
136
|
-
"Override default directory ('/var/snap/') where the snapshots will be mounted",
|
137
|
-
:default => '/var/snap/' do |dir|
|
138
|
-
unless File.directory?(dir)
|
139
|
-
raise ArgumentError, "Snapshot mount directory does not exist: #{dir}"
|
140
|
-
end
|
141
|
-
dir
|
142
|
-
end
|
143
|
-
option ['-b', '--snapshot-block-size'], 'SNAPSHOT_BLOCK_SIZE',
|
144
|
-
'Override default block size (2G)', :default => '2G'
|
145
|
-
|
146
|
-
def execute
|
147
|
-
perform_backup(:snapshot,
|
148
|
-
:snapshot_mount_dir => snapshot_mount_dir,
|
149
|
-
:snapshot_block_size => snapshot_block_size,
|
150
|
-
:include_db_dumps => include_db_dumps?)
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
# rubocop:disable Metrics/LineLength
|
155
130
|
class BackupCommand < Base
|
156
131
|
subcommand 'online', 'Keep services online during backup', OnlineBackupCommand
|
157
132
|
subcommand 'offline', 'Shut down services to preserve consistent backup', OfflineBackupCommand
|
158
|
-
subcommand 'snapshot', 'Use snapshots of the databases to create backup (DEPRECATED)', SnapshotBackupCommand
|
159
133
|
end
|
160
|
-
# rubocop:enable Metrics/LineLength
|
161
134
|
end
|
162
135
|
end
|
data/lib/foreman_maintain/cli.rb
CHANGED
@@ -13,6 +13,8 @@ require 'foreman_maintain/cli/packages_command'
|
|
13
13
|
require 'foreman_maintain/cli/plugin_command'
|
14
14
|
require 'foreman_maintain/cli/self_upgrade_command'
|
15
15
|
|
16
|
+
Clamp.allow_options_after_parameters = true
|
17
|
+
|
16
18
|
module ForemanMaintain
|
17
19
|
module Cli
|
18
20
|
class MainCommand < Base
|
@@ -115,10 +115,6 @@ module ForemanMaintain
|
|
115
115
|
@backup_dir ||= File.expand_path(ForemanMaintain.config.db_backup_dir)
|
116
116
|
end
|
117
117
|
|
118
|
-
def find_base_directory(directory)
|
119
|
-
find_dir_containing_file(directory, 'postgresql.conf')
|
120
|
-
end
|
121
|
-
|
122
118
|
def dropdb(config = configuration)
|
123
119
|
if local?
|
124
120
|
execute!("runuser - postgres -c 'dropdb #{config['database']}'")
|
@@ -56,10 +56,6 @@ module ForemanMaintain
|
|
56
56
|
rh_repos
|
57
57
|
end
|
58
58
|
|
59
|
-
def use_beta_repos?
|
60
|
-
ENV['FOREMAN_MAINTAIN_USE_BETA'] == '1'
|
61
|
-
end
|
62
|
-
|
63
59
|
def product_specific_repos(full_version)
|
64
60
|
repos = ["#{package_name}-#{full_version}-for-rhel-#{el_major_version}-x86_64-rpms"]
|
65
61
|
repos.concat(common_repos(full_version))
|
@@ -163,18 +163,6 @@ module ForemanMaintain
|
|
163
163
|
Dir.entries(dir).size <= 2
|
164
164
|
end
|
165
165
|
|
166
|
-
def get_lv_info(dir)
|
167
|
-
execute("findmnt -n --target #{dir} -o SOURCE,FSTYPE").split
|
168
|
-
end
|
169
|
-
|
170
|
-
def create_lv_snapshot(name, block_size, path)
|
171
|
-
execute!("lvcreate -n#{name} -L#{block_size} -s #{path}")
|
172
|
-
end
|
173
|
-
|
174
|
-
def get_lv_path(lv_name)
|
175
|
-
execute("lvs --noheadings -o lv_path -S lv_name=#{lv_name}").strip
|
176
|
-
end
|
177
|
-
|
178
166
|
def find_dir_containing_file(directory, target)
|
179
167
|
result = nil
|
180
168
|
Find.find(directory) do |path|
|
data/lib/foreman_maintain.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_maintain
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Nečas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clamp
|
@@ -163,7 +163,7 @@ files:
|
|
163
163
|
- definitions/checks/check_tmout.rb
|
164
164
|
- definitions/checks/disk/available_space.rb
|
165
165
|
- definitions/checks/disk/available_space_candlepin.rb
|
166
|
-
- definitions/checks/disk/
|
166
|
+
- definitions/checks/disk/available_space_postgresql13.rb
|
167
167
|
- definitions/checks/disk/performance.rb
|
168
168
|
- definitions/checks/env_proxy.rb
|
169
169
|
- definitions/checks/foreman/check_corrupted_roles.rb
|
@@ -242,20 +242,10 @@ files:
|
|
242
242
|
- definitions/procedures/backup/online/safety_confirmation.rb
|
243
243
|
- definitions/procedures/backup/prepare_directory.rb
|
244
244
|
- definitions/procedures/backup/pulp.rb
|
245
|
-
- definitions/procedures/backup/snapshot/clean_mount.rb
|
246
|
-
- definitions/procedures/backup/snapshot/logical_volume_confirmation.rb
|
247
|
-
- definitions/procedures/backup/snapshot/mount_base.rb
|
248
|
-
- definitions/procedures/backup/snapshot/mount_candlepin_db.rb
|
249
|
-
- definitions/procedures/backup/snapshot/mount_foreman_db.rb
|
250
|
-
- definitions/procedures/backup/snapshot/mount_pulp.rb
|
251
|
-
- definitions/procedures/backup/snapshot/mount_pulpcore_db.rb
|
252
|
-
- definitions/procedures/backup/snapshot/prepare_mount.rb
|
253
|
-
- definitions/procedures/backup/snapshot/snapshot_deprecation_message.rb
|
254
245
|
- definitions/procedures/crond/start.rb
|
255
246
|
- definitions/procedures/crond/stop.rb
|
256
247
|
- definitions/procedures/files/remove.rb
|
257
248
|
- definitions/procedures/foreman/fix_corrupted_roles.rb
|
258
|
-
- definitions/procedures/foreman/remove_duplicate_obsolete_roles.rb
|
259
249
|
- definitions/procedures/foreman/remove_duplicate_permissions.rb
|
260
250
|
- definitions/procedures/foreman_maintain_features.rb
|
261
251
|
- definitions/procedures/foreman_openscap/invalid_report_associations.rb
|
@@ -266,8 +256,6 @@ files:
|
|
266
256
|
- definitions/procedures/foreman_tasks/ui_investigate.rb
|
267
257
|
- definitions/procedures/hammer_setup.rb
|
268
258
|
- definitions/procedures/installer/run.rb
|
269
|
-
- definitions/procedures/installer/run_for_6_11.rb
|
270
|
-
- definitions/procedures/installer/upgrade.rb
|
271
259
|
- definitions/procedures/installer/upgrade_rake_task.rb
|
272
260
|
- definitions/procedures/knowledge_base_article.rb
|
273
261
|
- definitions/procedures/maintenance_mode/disable_maintenance_mode.rb
|
@@ -1,46 +0,0 @@
|
|
1
|
-
module Checks
|
2
|
-
module Disk
|
3
|
-
class AvailableSpacePostgresql12 < ForemanMaintain::Check
|
4
|
-
metadata do
|
5
|
-
label :available_space_for_postgresql12
|
6
|
-
description 'Check to make sure PostgreSQL 12 work directory has enough space for upgrade'
|
7
|
-
confine do
|
8
|
-
(feature(:foreman_database) || feature(:candlepin_database)) && \
|
9
|
-
(file_exists?('/var/lib/pgsql') && \
|
10
|
-
file_exists?('/var/opt/rh/rh-postgresql12'))
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def run
|
15
|
-
assert(psql_12_available_space >= psql_9_consumed_space, warning_message, :warn => true)
|
16
|
-
end
|
17
|
-
|
18
|
-
def pgsql_dir(version)
|
19
|
-
case version
|
20
|
-
when 9
|
21
|
-
'/var/lib/pgsql/'
|
22
|
-
when 12
|
23
|
-
'/var/opt/rh/rh-postgresql12/'
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def psql_9_consumed_space
|
28
|
-
io_obj = ForemanMaintain::Utils::Disk::IODevice.new(pgsql_dir(9))
|
29
|
-
io_obj.space_used
|
30
|
-
end
|
31
|
-
|
32
|
-
def psql_12_available_space
|
33
|
-
io_obj = ForemanMaintain::Utils::Disk::IODevice.new(pgsql_dir(12))
|
34
|
-
io_obj.available_space
|
35
|
-
end
|
36
|
-
|
37
|
-
def warning_message
|
38
|
-
sat_version = feature(:satellite).current_version.version[0..2]
|
39
|
-
"Satellite #{sat_version} uses PostgreSQL 12. \nThis changes PostgreSQL "\
|
40
|
-
"work directory to #{pgsql_dir(12)}\n"\
|
41
|
-
"The new work directory requires at least #{psql_9_consumed_space}"\
|
42
|
-
'MiB free space for upgrade!'
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
module Procedures::Backup
|
2
|
-
module Snapshot
|
3
|
-
class CleanMount < ForemanMaintain::Procedure
|
4
|
-
metadata do
|
5
|
-
description 'Remove the snapshot mount points'
|
6
|
-
tags :backup
|
7
|
-
param :mount_dir, 'Snapshot mount directory', :required => true
|
8
|
-
end
|
9
|
-
|
10
|
-
def run
|
11
|
-
%w[pulp pgsql].each do |database|
|
12
|
-
mount_point = File.join(@mount_dir, database)
|
13
|
-
|
14
|
-
if File.exist?(mount_point) && !execute("mount|grep #{mount_point}").empty?
|
15
|
-
execute("umount #{mount_point}")
|
16
|
-
end
|
17
|
-
|
18
|
-
snapshot_location = get_lv_path("#{database}-snap")
|
19
|
-
execute("lvremove #{snapshot_location} -f") unless snapshot_location.empty?
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
module Procedures::Backup
|
2
|
-
module Snapshot
|
3
|
-
class LogicalVolumeConfirmation < ForemanMaintain::Procedure
|
4
|
-
metadata do
|
5
|
-
description 'Check if backup is on different logical volume then the source'
|
6
|
-
tags :backup
|
7
|
-
param :backup_dir, 'Directory where to backup to', :required => true
|
8
|
-
param :skip_pulp, 'Skip Pulp content during backup'
|
9
|
-
end
|
10
|
-
|
11
|
-
def run
|
12
|
-
backup_lv = get_lv_info(@backup_dir)
|
13
|
-
shared_lv = dbs.inject([]) do |list, (db_label, db_name)|
|
14
|
-
db_lv = get_lv_info(feature(db_label).data_dir)
|
15
|
-
list << db_name if db_lv == backup_lv
|
16
|
-
list
|
17
|
-
end
|
18
|
-
|
19
|
-
pulp_data_lv = get_lv_info(current_pulp_feature.pulp_data_dir)
|
20
|
-
shared_lv << 'Pulp' if pulp_data_lv == backup_lv && !@skip_pulp
|
21
|
-
|
22
|
-
confirm(shared_lv) if shared_lv.any?
|
23
|
-
end
|
24
|
-
|
25
|
-
def current_pulp_feature
|
26
|
-
feature(:pulpcore_database)
|
27
|
-
end
|
28
|
-
|
29
|
-
def dbs
|
30
|
-
dbs = {}
|
31
|
-
dbs[:candlepin_database] = 'Candlepin' if db_local?(:candlepin_database)
|
32
|
-
dbs[:foreman_database] = 'Foreman' if db_local?(:foreman_database)
|
33
|
-
dbs[:pulpcore_database] = 'Pulpcore' if db_local?(:pulpcore_database)
|
34
|
-
dbs
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
def db_local?(db)
|
40
|
-
feature(:instance).database_local?(db)
|
41
|
-
end
|
42
|
-
|
43
|
-
def confirm(shared_lv)
|
44
|
-
answer = ask_decision('*** WARNING: The chosen backup location is mounted on the same' \
|
45
|
-
" logical volume as the location of #{shared_lv.join(', ')}.\n" \
|
46
|
-
'*** It is highly suggested to backup to a different logical volume than' \
|
47
|
-
" the #{shared_lv.join(', ')} database.\n" \
|
48
|
-
'*** If you would like to continue, the snapshot size will be required to be at least' \
|
49
|
-
" the size of the actual #{shared_lv.join(', ')} database.\n" \
|
50
|
-
"*** You can skip this confirmation with the '-y' flag.\n\n" \
|
51
|
-
'Do you want to proceed?', actions_msg: 'y(yes), q(quit)')
|
52
|
-
abort! unless answer == :yes
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
module Procedures::Backup
|
2
|
-
module Snapshot
|
3
|
-
class MountBase < ForemanMaintain::Procedure
|
4
|
-
metadata do
|
5
|
-
advanced_run false
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.common_params(context)
|
9
|
-
context.instance_eval do
|
10
|
-
param :mount_dir, 'Snapshot mount directory', :required => true
|
11
|
-
param :block_size, 'Snapshot block size', :default => '2G'
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def mount_snapshot(database, lv_type)
|
16
|
-
FileUtils.mkdir_p(mount_location(database))
|
17
|
-
options = (lv_type == 'xfs') ? '-onouuid,ro' : '-oro'
|
18
|
-
lv_name = "#{database}-snap"
|
19
|
-
execute!("mount #{get_lv_path(lv_name)} #{mount_location(database)} #{options}")
|
20
|
-
end
|
21
|
-
|
22
|
-
def mount_location(database)
|
23
|
-
File.join(@mount_dir, database)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'procedures/backup/snapshot/mount_base'
|
2
|
-
module Procedures::Backup
|
3
|
-
module Snapshot
|
4
|
-
class MountCandlepinDB < MountBase
|
5
|
-
metadata do
|
6
|
-
description 'Create and mount snapshot of Candlepin DB'
|
7
|
-
tags :backup
|
8
|
-
label :backup_snapshot_mount_candlepin_db
|
9
|
-
for_feature :candlepin_database
|
10
|
-
preparation_steps { Checks::Candlepin::DBUp.new unless feature(:candlepin_database).local? }
|
11
|
-
MountBase.common_params(self)
|
12
|
-
param :backup_dir, 'Directory where to backup to'
|
13
|
-
end
|
14
|
-
|
15
|
-
def run
|
16
|
-
if feature(:candlepin_database).local?
|
17
|
-
snapshot
|
18
|
-
else
|
19
|
-
dump_candlepin
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
def dump_candlepin
|
26
|
-
puts 'LV snapshots are not supported for remote databases. Doing postgres dump instead... '
|
27
|
-
with_spinner('Getting Candlepin DB dump') do
|
28
|
-
feature(:candlepin_database).dump_db(File.join(@backup_dir, 'candlepin.dump'))
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def snapshot
|
33
|
-
mount_point = mount_location('pgsql')
|
34
|
-
FileUtils.mkdir_p(mount_point) unless File.directory?(mount_point)
|
35
|
-
if directory_empty?(mount_point)
|
36
|
-
with_spinner('Creating snapshot of Postgres') do |spinner|
|
37
|
-
lv_info = get_lv_info(feature(:candlepin_database).data_dir)
|
38
|
-
create_lv_snapshot('pgsql-snap', @block_size, lv_info[0])
|
39
|
-
spinner.update("Mounting snapshot of Postgres on #{mount_point}")
|
40
|
-
mount_snapshot('pgsql', lv_info[1])
|
41
|
-
end
|
42
|
-
else
|
43
|
-
puts 'Snapshot of Postgres is already mounted'
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'procedures/backup/snapshot/mount_base'
|
2
|
-
module Procedures::Backup
|
3
|
-
module Snapshot
|
4
|
-
class MountForemanDB < MountBase
|
5
|
-
metadata do
|
6
|
-
description 'Create and mount snapshot of Foreman DB'
|
7
|
-
tags :backup
|
8
|
-
label :backup_snapshot_mount_foreman_db
|
9
|
-
for_feature :foreman_database
|
10
|
-
preparation_steps { Checks::Foreman::DBUp.new unless feature(:foreman_database).local? }
|
11
|
-
MountBase.common_params(self)
|
12
|
-
param :backup_dir, 'Directory where to backup to'
|
13
|
-
end
|
14
|
-
|
15
|
-
def run
|
16
|
-
if feature(:foreman_database).local?
|
17
|
-
snapshot
|
18
|
-
else
|
19
|
-
dump_foreman
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
def dump_foreman
|
26
|
-
puts 'LV snapshots are not supported for remote databases. Doing postgres dump instead... '
|
27
|
-
with_spinner('Getting Foreman DB dump') do
|
28
|
-
feature(:foreman_database).dump_db(File.join(@backup_dir, 'foreman.dump'))
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def snapshot
|
33
|
-
mount_point = mount_location('pgsql')
|
34
|
-
FileUtils.mkdir_p(mount_point) unless File.directory?(mount_point)
|
35
|
-
if directory_empty?(mount_point)
|
36
|
-
with_spinner('Creating snapshot of Postgres') do |spinner|
|
37
|
-
lv_info = get_lv_info(feature(:foreman_database).data_dir)
|
38
|
-
create_lv_snapshot('pgsql-snap', @block_size, lv_info[0])
|
39
|
-
spinner.update("Mounting snapshot of Postgres on #{mount_point}")
|
40
|
-
mount_snapshot('pgsql', lv_info[1])
|
41
|
-
end
|
42
|
-
else
|
43
|
-
puts 'Snapshot of Postgres is already mounted'
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'procedures/backup/snapshot/mount_base'
|
2
|
-
module Procedures::Backup
|
3
|
-
module Snapshot
|
4
|
-
class MountPulp < MountBase
|
5
|
-
metadata do
|
6
|
-
description 'Create and mount snapshot of Pulp data'
|
7
|
-
tags :backup
|
8
|
-
MountBase.common_params(self)
|
9
|
-
param :skip, 'Skip Pulp content during backup'
|
10
|
-
confine do
|
11
|
-
feature(:pulpcore_database)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def run
|
16
|
-
skip if @skip
|
17
|
-
with_spinner('Creating snapshot of Pulp') do |spinner|
|
18
|
-
current_pulp_feature.with_marked_directory(current_pulp_feature.pulp_data_dir) do
|
19
|
-
lv_info = get_lv_info(current_pulp_feature.pulp_data_dir)
|
20
|
-
create_lv_snapshot('pulp-snap', @block_size, lv_info[0])
|
21
|
-
spinner.update("Mounting snapshot of Pulp on #{mount_location('pulp')}")
|
22
|
-
mount_snapshot('pulp', lv_info[1])
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def current_pulp_feature
|
28
|
-
feature(:pulpcore_database)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'procedures/backup/snapshot/mount_base'
|
2
|
-
module Procedures::Backup
|
3
|
-
module Snapshot
|
4
|
-
class MountPulpcoreDB < MountBase
|
5
|
-
metadata do
|
6
|
-
description 'Create and mount snapshot of Pulpcore DB'
|
7
|
-
tags :backup
|
8
|
-
label :backup_snapshot_mount_pulpcore_db
|
9
|
-
for_feature :pulpcore_database
|
10
|
-
preparation_steps { Checks::Pulpcore::DBUp.new unless feature(:pulpcore_database).local? }
|
11
|
-
MountBase.common_params(self)
|
12
|
-
param :backup_dir, 'Directory where to backup to'
|
13
|
-
end
|
14
|
-
|
15
|
-
def run
|
16
|
-
if feature(:pulpcore_database).local?
|
17
|
-
snapshot
|
18
|
-
else
|
19
|
-
dump_pulpcore
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
def dump_pulpcore
|
26
|
-
puts 'LV snapshots are not supported for remote databases. Doing postgres dump instead... '
|
27
|
-
with_spinner('Getting Pulpcore DB dump') do
|
28
|
-
feature(:pulpcore_database).dump_db(File.join(@backup_dir, 'pulpcore.dump'))
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def snapshot
|
33
|
-
mount_point = mount_location('pgsql')
|
34
|
-
FileUtils.mkdir_p(mount_point) unless File.directory?(mount_point)
|
35
|
-
if directory_empty?(mount_point)
|
36
|
-
with_spinner('Creating snapshot of Postgres') do |spinner|
|
37
|
-
lv_info = get_lv_info(feature(:pulpcore_database).data_dir)
|
38
|
-
create_lv_snapshot('pgsql-snap', @block_size, lv_info[0])
|
39
|
-
spinner.update("Mounting snapshot of Postgres on #{mount_point}")
|
40
|
-
mount_snapshot('pgsql', lv_info[1])
|
41
|
-
end
|
42
|
-
else
|
43
|
-
puts 'Snapshot of Postgres is already mounted'
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module Procedures::Backup
|
2
|
-
module Snapshot
|
3
|
-
class PrepareMount < ForemanMaintain::Procedure
|
4
|
-
metadata do
|
5
|
-
description 'Prepare mount point for the snapshot'
|
6
|
-
tags :backup
|
7
|
-
param :mount_dir, 'Snapshot mount directory', :required => true
|
8
|
-
end
|
9
|
-
|
10
|
-
def run
|
11
|
-
logger.debug("Creating snap dir: #{@mount_dir}")
|
12
|
-
FileUtils.mkdir_p @mount_dir
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
module Procedures::Backup
|
2
|
-
module Snapshot
|
3
|
-
class SnapshotDeprecationMessage < ForemanMaintain::Procedure
|
4
|
-
metadata do
|
5
|
-
description 'Snapshot backups are deprecated'
|
6
|
-
tags :backup
|
7
|
-
end
|
8
|
-
|
9
|
-
def run
|
10
|
-
set_warn('Snapshot backups are deprecated and will be removed in a future version.')
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|