foreman_maintain 1.6.12 → 1.6.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7357cec0fa22b76e7ae0c7d2da85e2cb20f52aeb2ded53e9a2ddf21c56b7a037
4
- data.tar.gz: 2116a2048dc315a55bb7fb8789e9961f2a4fc91a4afa5b614dd237eb7825da37
3
+ metadata.gz: 0e0b033f2189945ae0f5b3a005ee7513d7046f958ffa8bb8693ddc2c95521db1
4
+ data.tar.gz: 62ca2e1a8404fa3d30309feceafc53d659519f4595ab60cecbde58ad8e69290c
5
5
  SHA512:
6
- metadata.gz: 5a14594384dd60070ffde442e87423522ebde81e3f9580ac88c74028bb33a232bbe4bf57e7847d70768c82b375c5067509dfefed5ecc7c79023f66a2c904af11
7
- data.tar.gz: 07fc2c9e32f3d16171a99839562dd01210190c00de03414859dfb84492401168d2127d84974ac750c7b5aaa47a927bd6ea42cc47237249c908ac56f96749e7d0
6
+ metadata.gz: a6f47ab3d231627d634fc8ce93d31853de8da33bb84ac02c483077bb71270bb413d90e9f721820237227c2ea6e3bdeb3df2bb610f33c8a9e5cae67e4bd13a73c
7
+ data.tar.gz: ad2f03840152f21a868b881973267fc48e511c8c48115666b5b5cfc4685c753bb18f27c4a6f476dda624f7ee0c69f57a1702759b7a0c3a5b874034bda04df90b
@@ -5,7 +5,6 @@ module Checks::Backup
5
5
  tags :backup
6
6
  param :incremental_dir, 'Path to existing backup directory'
7
7
  param :online_backup, 'Select for online backup', :flag => true, :default => false
8
- param :sql_tar, 'Will backup include PostgreSQL tarball', :flag => true, :default => false
9
8
  manual_detection
10
9
  end
11
10
 
@@ -25,11 +24,9 @@ module Checks::Backup
25
24
  assert(existing_type == new_type, msg)
26
25
 
27
26
  unless @online_backup
28
- existing_sql = backup.sql_tar_files_exist? ? 'tarball' : 'dump'
29
- new_sql = @sql_tar ? 'tarball' : 'dump'
30
- msg = "The existing backup has PostgreSQL as a #{existing_sql}, "\
31
- "but the new one will have a #{new_sql}."
32
- assert(existing_sql == new_sql, msg)
27
+ msg = "The existing backup has PostgreSQL as a tarball, "\
28
+ "but the new one will have a dump."
29
+ assert(!backup.sql_tar_files_exist?, msg)
33
30
  end
34
31
  end
35
32
  end
@@ -11,7 +11,7 @@ module Checks::Restore
11
11
 
12
12
  def run
13
13
  backup = ForemanMaintain::Utils::Backup.new(@backup_dir)
14
- if feature(:instance).postgresql_local? && backup.online_backup?
14
+ if feature(:instance).postgresql_local?
15
15
  errors = []
16
16
  [:candlepin_dump, :foreman_dump, :pulpcore_dump].each do |dump|
17
17
  next unless backup.file_map[dump][:present]
@@ -2,7 +2,7 @@ module Procedures::Backup
2
2
  module Online
3
3
  class CandlepinDB < ForemanMaintain::Procedure
4
4
  metadata do
5
- description 'Backup Candlepin database online'
5
+ description 'Backup Candlepin database'
6
6
  tags :backup
7
7
  label :backup_online_candlepin_db
8
8
  for_feature :candlepin_database
@@ -2,7 +2,7 @@ module Procedures::Backup
2
2
  module Online
3
3
  class ForemanDB < ForemanMaintain::Procedure
4
4
  metadata do
5
- description 'Backup Foreman database online'
5
+ description 'Backup Foreman database'
6
6
  tags :backup
7
7
  label :backup_online_foreman_db
8
8
  for_feature :foreman_database
@@ -2,7 +2,7 @@ module Procedures::Backup
2
2
  module Online
3
3
  class PulpcoreDB < ForemanMaintain::Procedure
4
4
  metadata do
5
- description 'Backup Pulpcore database online'
5
+ description 'Backup Pulpcore database'
6
6
  tags :backup
7
7
  label :backup_online_pulpcore_db
8
8
  for_feature :pulpcore_database
@@ -4,23 +4,20 @@ module Procedures::Backup
4
4
  metadata do
5
5
  description 'Data consistency warning'
6
6
  tags :backup
7
- param :include_db_dumps, 'Are database dumps included in backup', :flag => true,
8
- :default => false
9
7
  end
10
8
 
11
9
  def run
12
- answer = ask_decision(warning_message(@include_db_dumps), actions_msg: 'y(yes), q(quit)')
10
+ answer = ask_decision(warning_message, actions_msg: 'y(yes), q(quit)')
13
11
  abort! unless answer == :yes
14
12
  end
15
13
 
16
- def warning_message(include_db_dumps)
17
- substr = include_db_dumps ? 'database dump' : 'online backup'
18
- "*** WARNING: The #{substr} is intended for making a copy of the data\n" \
14
+ def warning_message
15
+ "*** WARNING: The online backup is intended for making a copy of the data\n" \
19
16
  '*** for debugging purposes only.' \
20
17
  " The backup routine can not ensure 100% consistency while the\n" \
21
18
  "*** backup is taking place as there is a chance there may be data mismatch between\n" \
22
19
  '*** the databases while the services are live.' \
23
- " If you wish to utilize the #{substr}\n" \
20
+ " If you wish to utilize the online backup\n" \
24
21
  '*** for production use you need to ensure that there are' \
25
22
  " no modifications occurring during\n" \
26
23
  "*** your backup run.\n\nDo you want to proceed?"
@@ -6,7 +6,6 @@ module Procedures::Backup
6
6
  param :backup_dir, 'Directory where to backup to', :required => true
7
7
  param :preserve_dir, 'Directory where to backup to', :flag => true
8
8
  param :incremental_dir, 'Changes since specified backup only'
9
- param :online_backup, 'Select for online backup', :flag => true, :default => false
10
9
  end
11
10
 
12
11
  # rubocop:disable Metrics/MethodLength
@@ -17,7 +16,7 @@ module Procedures::Backup
17
16
  FileUtils.mkdir_p @backup_dir
18
17
  FileUtils.chmod_R 0o770, @backup_dir
19
18
 
20
- if feature(:instance).postgresql_local? && @online_backup
19
+ if feature(:instance).postgresql_local?
21
20
  begin
22
21
  FileUtils.chown_R(nil, 'postgres', @backup_dir)
23
22
  rescue Errno::EPERM
@@ -8,7 +8,6 @@ module ForemanMaintain::Scenarios
8
8
  param :strategy, 'Backup strategy. One of [:online, :offline]',
9
9
  :required => true
10
10
  param :backup_dir, 'Directory where to backup to', :required => true
11
- param :include_db_dumps, 'Include dumps of local dbs as part of offline'
12
11
  param :preserve_dir, 'Directory where to backup to'
13
12
  param :incremental_dir, 'Changes since specified backup only'
14
13
  param :proxy_features, 'List of proxy features to backup (default: all)', :array => true
@@ -19,12 +18,10 @@ module ForemanMaintain::Scenarios
19
18
  def compose
20
19
  check_valid_strategy
21
20
  add_step_with_context(Checks::Backup::IncrementalParentType,
22
- :online_backup => strategy == :online,
23
- :sql_tar => feature(:instance).postgresql_local?)
21
+ :online_backup => strategy == :online)
24
22
  safety_confirmation
25
23
  add_step_with_context(Procedures::Backup::AccessibilityConfirmation) if strategy == :offline
26
- add_step_with_context(Procedures::Backup::PrepareDirectory,
27
- :online_backup => strategy == :online)
24
+ add_step_with_context(Procedures::Backup::PrepareDirectory)
28
25
  add_step_with_context(Procedures::Backup::Metadata, :online_backup => strategy == :online)
29
26
 
30
27
  case strategy
@@ -47,10 +44,7 @@ module ForemanMaintain::Scenarios
47
44
  Procedures::Backup::Pulp => :backup_dir,
48
45
  Procedures::Backup::Online::CandlepinDB => :backup_dir,
49
46
  Procedures::Backup::Online::ForemanDB => :backup_dir,
50
- Procedures::Backup::Online::PulpcoreDB => :backup_dir,
51
- Procedures::Backup::Offline::CandlepinDB => :backup_dir,
52
- Procedures::Backup::Offline::ForemanDB => :backup_dir,
53
- Procedures::Backup::Offline::PulpcoreDB => :backup_dir)
47
+ Procedures::Backup::Online::PulpcoreDB => :backup_dir)
54
48
  context.map(:preserve_dir,
55
49
  Procedures::Backup::PrepareDirectory => :preserve_dir)
56
50
  context.map(:incremental_dir,
@@ -63,15 +57,13 @@ module ForemanMaintain::Scenarios
63
57
  Procedures::Backup::Pulp => :skip)
64
58
  context.map(:tar_volume_size,
65
59
  Procedures::Backup::Pulp => :tar_volume_size)
66
- context.map(:include_db_dumps,
67
- Procedures::Backup::Online::SafetyConfirmation => :include_db_dumps)
68
60
  end
69
61
  # rubocop:enable Metrics/MethodLength
70
62
 
71
63
  private
72
64
 
73
65
  def safety_confirmation
74
- if strategy == :online || include_db_dumps?
66
+ if strategy == :online
75
67
  add_step_with_context(Procedures::Backup::Online::SafetyConfirmation)
76
68
  end
77
69
  end
@@ -83,35 +75,30 @@ module ForemanMaintain::Scenarios
83
75
  end
84
76
 
85
77
  def add_offline_backup_steps
86
- include_dumps if include_db_dumps?
87
78
  add_step_with_context(Procedures::ForemanProxy::Features, :load_only => true)
88
79
  add_steps_with_context(
89
80
  Procedures::Service::Stop,
90
81
  Procedures::Backup::ConfigFiles,
91
- Procedures::Backup::Pulp,
92
- Procedures::Backup::Offline::CandlepinDB,
93
- Procedures::Backup::Offline::ForemanDB,
94
- Procedures::Backup::Offline::PulpcoreDB,
95
- Procedures::Service::Start
82
+ Procedures::Backup::Pulp
96
83
  )
97
- end
98
84
 
99
- def include_dumps
100
- if feature(:instance).database_local?(:candlepin_database)
101
- add_step_with_context(Procedures::Backup::Online::CandlepinDB)
102
- end
103
- if feature(:instance).database_local?(:foreman_database)
104
- add_step_with_context(Procedures::Backup::Online::ForemanDB)
105
- end
106
- if feature(:instance).database_local?(:pulpcore_database)
107
- add_step_with_context(Procedures::Backup::Online::PulpcoreDB)
85
+ if feature(:instance).postgresql_local?
86
+ add_step(Procedures::Service::Start.new(:only => ['postgresql']))
108
87
  end
88
+
89
+ add_database_backup_steps
90
+
91
+ add_steps_with_context(Procedures::Service::Start)
109
92
  end
110
93
 
111
94
  def add_online_backup_steps
112
95
  add_step_with_context(Procedures::Backup::ConfigFiles, :ignore_changed_files => true,
113
96
  :online_backup => true)
114
97
  add_step_with_context(Procedures::Backup::Pulp, :ensure_unchanged => true)
98
+ add_database_backup_steps
99
+ end
100
+
101
+ def add_database_backup_steps
115
102
  add_steps_with_context(
116
103
  Procedures::Backup::Online::CandlepinDB,
117
104
  Procedures::Backup::Online::ForemanDB,
@@ -122,10 +109,6 @@ module ForemanMaintain::Scenarios
122
109
  def strategy
123
110
  context.get(:strategy)
124
111
  end
125
-
126
- def include_db_dumps?
127
- !!context.get(:include_db_dumps)
128
- end
129
112
  end
130
113
 
131
114
  class BackupRescueCleanup < ForemanMaintain::Scenario
@@ -3,6 +3,11 @@ module Scenarios::Update
3
3
  def self.update_metadata(&block)
4
4
  metadata do
5
5
  tags :update_scenario
6
+
7
+ confine do
8
+ feature(:instance).target_version == feature(:instance).current_version.to_s[/^\d+\.\d+/]
9
+ end
10
+
6
11
  instance_eval(&block)
7
12
  end
8
13
  end
@@ -119,11 +119,9 @@ module ForemanMaintain
119
119
  include BackupCommon
120
120
  interactive_option
121
121
  common_backup_options
122
- option '--include-db-dumps', :flag, 'Also dump full database schema before offline backup'
123
122
 
124
123
  def execute
125
- perform_backup(:offline,
126
- :include_db_dumps => include_db_dumps?)
124
+ perform_backup(:offline)
127
125
  end
128
126
  end
129
127
 
@@ -1,3 +1,3 @@
1
1
  module ForemanMaintain
2
- VERSION = '1.6.12'.freeze
2
+ VERSION = '1.6.14'.freeze
3
3
  end
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.6.12
4
+ version: 1.6.14
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-07-11 00:00:00.000000000 Z
11
+ date: 2024-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clamp
@@ -235,9 +235,6 @@ files:
235
235
  - definitions/procedures/backup/compress_data.rb
236
236
  - definitions/procedures/backup/config_files.rb
237
237
  - definitions/procedures/backup/metadata.rb
238
- - definitions/procedures/backup/offline/candlepin_db.rb
239
- - definitions/procedures/backup/offline/foreman_db.rb
240
- - definitions/procedures/backup/offline/pulpcore_db.rb
241
238
  - definitions/procedures/backup/online/candlepin_db.rb
242
239
  - definitions/procedures/backup/online/foreman_db.rb
243
240
  - definitions/procedures/backup/online/pulpcore_db.rb
@@ -1,53 +0,0 @@
1
- module Procedures::Backup
2
- module Offline
3
- class CandlepinDB < ForemanMaintain::Procedure
4
- metadata do
5
- description 'Backup Candlepin DB offline'
6
- tags :backup
7
- label :backup_offline_candlepin_db
8
- for_feature :candlepin_database
9
- preparation_steps { Checks::Candlepin::DBUp.new unless feature(:candlepin_database).local? }
10
- param :backup_dir, 'Directory where to backup to', :required => true
11
- param :tar_volume_size, 'Size of tar volume (indicates splitting)'
12
- end
13
-
14
- def run
15
- if feature(:candlepin_database).local?
16
- if File.exist?(pg_backup_file)
17
- puts 'Already done'
18
- else
19
- local_backup
20
- end
21
- else
22
- puts "Backup of #{pg_data_dir} is not supported for remote databases." \
23
- ' Doing postgres dump instead...'
24
- with_spinner('Getting Candlepin DB dump') do
25
- feature(:candlepin_database).dump_db(File.join(@backup_dir, 'candlepin.dump'))
26
- end
27
- end
28
- end
29
-
30
- private
31
-
32
- def local_backup
33
- with_spinner("Collecting data from #{pg_data_dir}") do
34
- feature(:candlepin_database).backup_local(
35
- pg_backup_file,
36
- :listed_incremental => File.join(@backup_dir, '.postgres.snar'),
37
- :volume_size => @tar_volume_size,
38
- :data_dir => pg_data_dir,
39
- :restore_dir => feature(:candlepin_database).data_dir
40
- )
41
- end
42
- end
43
-
44
- def pg_backup_file
45
- File.join(@backup_dir, 'pgsql_data.tar')
46
- end
47
-
48
- def pg_data_dir
49
- feature(:candlepin_database).data_dir
50
- end
51
- end
52
- end
53
- end
@@ -1,73 +0,0 @@
1
- module Procedures::Backup
2
- module Offline
3
- class ForemanDB < ForemanMaintain::Procedure
4
- metadata do
5
- description 'Backup Foreman DB offline'
6
- tags :backup
7
- label :backup_offline_foreman_db
8
- for_feature :foreman_database
9
- preparation_steps { Checks::Foreman::DBUp.new unless feature(:foreman_database).local? }
10
- param :backup_dir, 'Directory where to backup to', :required => true
11
- param :tar_volume_size, 'Size of tar volume (indicates splitting)'
12
- end
13
-
14
- def run
15
- if feature(:foreman_database).local?
16
- if File.exist?(pg_backup_file)
17
- puts 'Already done'
18
- else
19
- local_backup
20
- end
21
- else
22
- puts "Backup of #{pg_data_dirs.join(',')} is not supported for remote databases." \
23
- ' Doing postgres dump instead...'
24
- with_spinner('Getting Foreman DB dump') do
25
- feature(:foreman_database).dump_db(File.join(@backup_dir, 'foreman.dump'))
26
- end
27
- end
28
- end
29
-
30
- private
31
-
32
- def local_backup
33
- with_spinner("Collecting data from #{pg_data_dirs.join(',')}") do
34
- pg_data_dirs.each_with_index do |pg_dir, index|
35
- do_backup(pg_dir, (index == 0) ? 'create' : 'append')
36
- end
37
- end
38
- end
39
-
40
- def do_backup(pg_dir, cmd)
41
- restore_dir = el? ? feature(:foreman_database).data_dir : pg_dir
42
- feature(:foreman_database).backup_local(
43
- pg_backup_file,
44
- :listed_incremental => File.join(@backup_dir, '.postgres.snar'),
45
- :volume_size => @tar_volume_size,
46
- :data_dir => pg_dir,
47
- :restore_dir => restore_dir,
48
- :command => cmd
49
- )
50
- end
51
-
52
- def pg_backup_file
53
- File.join(@backup_dir, 'pgsql_data.tar')
54
- end
55
-
56
- def pg_data_dirs
57
- el? ? [pg_data_dir_el] : pg_data_dirs_deb
58
- end
59
-
60
- def pg_data_dirs_deb
61
- # The Debian based OSes support multiple installations of Postgresql
62
- # There could be situations where Foreman db is either of these versions
63
- # To be sure we backup the system correctly without missing anything
64
- # we backup all of the Postgresql dirs
65
- feature(:foreman_database).data_dir
66
- end
67
-
68
- def pg_data_dir_el
69
- feature(:foreman_database).data_dir
70
- end
71
- end
72
- end
73
- end
@@ -1,53 +0,0 @@
1
- module Procedures::Backup
2
- module Offline
3
- class PulpcoreDB < ForemanMaintain::Procedure
4
- metadata do
5
- description 'Backup Pulpcore DB offline'
6
- tags :backup
7
- label :backup_offline_pulpcore_db
8
- for_feature :pulpcore_database
9
- preparation_steps { Checks::Pulpcore::DBUp.new unless feature(:pulpcore_database).local? }
10
- param :backup_dir, 'Directory where to backup to', :required => true
11
- param :tar_volume_size, 'Size of tar volume (indicates splitting)'
12
- end
13
-
14
- def run
15
- if feature(:pulpcore_database).local?
16
- if File.exist?(pg_backup_file)
17
- puts 'Already done'
18
- else
19
- local_backup
20
- end
21
- else
22
- puts "Backup of #{pg_data_dir} is not supported for remote databases." \
23
- ' Doing postgres dump instead...'
24
- with_spinner('Getting Pulpcore DB dump') do
25
- feature(:pulpcore_database).dump_db(File.join(@backup_dir, 'pulpcore.dump'))
26
- end
27
- end
28
- end
29
-
30
- private
31
-
32
- def local_backup
33
- with_spinner("Collecting data from #{pg_data_dir}") do
34
- feature(:pulpcore_database).backup_local(
35
- pg_backup_file,
36
- :listed_incremental => File.join(@backup_dir, '.postgres.snar'),
37
- :volume_size => @tar_volume_size,
38
- :data_dir => pg_data_dir,
39
- :restore_dir => feature(:pulpcore_database).data_dir
40
- )
41
- end
42
- end
43
-
44
- def pg_backup_file
45
- File.join(@backup_dir, 'pgsql_data.tar')
46
- end
47
-
48
- def pg_data_dir
49
- feature(:pulpcore_database).data_dir
50
- end
51
- end
52
- end
53
- end