travis-backup 0.1.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +1 -1
- data/README.md +14 -4
- data/lib/backup/load_from_files.rb +245 -0
- data/lib/backup/move_logs.rb +43 -0
- data/lib/backup/remove_orphans.rb +177 -0
- data/lib/backup/remove_specified/remove_heavy_data.rb +99 -0
- data/lib/backup/remove_specified/remove_with_all_dependencies.rb +51 -0
- data/lib/backup/remove_specified/shared.rb +20 -0
- data/lib/backup/remove_specified.rb +68 -0
- data/lib/backup/save_file.rb +43 -0
- data/lib/backup/save_id_hash_to_file.rb +33 -0
- data/lib/backup/save_nullified_rels_to_file.rb +29 -0
- data/lib/config.rb +37 -7
- data/lib/db_helper.rb +27 -0
- data/lib/dry_run_reporter.rb +47 -0
- data/lib/id_hash.rb +97 -0
- data/lib/ids_of_all_dependencies.rb +330 -0
- data/lib/model.rb +77 -0
- data/lib/models/abuse.rb +9 -0
- data/lib/models/annotation.rb +8 -0
- data/lib/models/branch.rb +9 -1
- data/lib/models/broadcast.rb +8 -0
- data/lib/models/build.rb +23 -3
- data/lib/models/commit.rb +8 -1
- data/lib/models/cron.rb +2 -1
- data/lib/models/email.rb +8 -0
- data/lib/models/invoice.rb +8 -0
- data/lib/models/job.rb +10 -2
- data/lib/models/log.rb +1 -1
- data/lib/models/membership.rb +9 -0
- data/lib/models/message.rb +8 -0
- data/lib/models/organization.rb +15 -1
- data/lib/models/owner_group.rb +8 -0
- data/lib/models/permission.rb +9 -0
- data/lib/models/pull_request.rb +5 -1
- data/lib/models/queueable_job.rb +8 -0
- data/lib/models/repository.rb +16 -3
- data/lib/models/request.rb +11 -1
- data/lib/models/ssl_key.rb +2 -1
- data/lib/models/stage.rb +4 -1
- data/lib/models/star.rb +9 -0
- data/lib/models/subscription.rb +9 -0
- data/lib/models/tag.rb +7 -1
- data/lib/models/token.rb +8 -0
- data/lib/models/trial.rb +9 -0
- data/lib/models/trial_allowance.rb +9 -0
- data/lib/models/user.rb +33 -1
- data/lib/models/user_beta_feature.rb +8 -0
- data/lib/nullify_dependencies.rb +42 -0
- data/lib/travis-backup.rb +40 -266
- data/travis-backup.gemspec +2 -1
- metadata +53 -9
- data/Gemfile.lock +0 -212
- data/lib/models/model.rb +0 -8
data/lib/models/request.rb
CHANGED
@@ -1,10 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'model'
|
4
4
|
require 'models/repository'
|
5
5
|
|
6
6
|
class Request < Model
|
7
|
+
belongs_to :owner, polymorphic: true
|
8
|
+
belongs_to :sender, polymorphic: true
|
7
9
|
belongs_to :repository
|
10
|
+
belongs_to :branch
|
11
|
+
belongs_to :pull_request
|
12
|
+
belongs_to :tag
|
13
|
+
belongs_to :commit
|
14
|
+
has_many :abuses
|
15
|
+
has_many :messages, as: :subject
|
16
|
+
has_many :jobs, as: :source
|
17
|
+
has_many :builds
|
8
18
|
|
9
19
|
self.table_name = 'requests'
|
10
20
|
end
|
data/lib/models/ssl_key.rb
CHANGED
data/lib/models/stage.rb
CHANGED
data/lib/models/star.rb
ADDED
data/lib/models/tag.rb
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'model'
|
4
4
|
|
5
5
|
class Tag < Model
|
6
|
+
belongs_to :last_build, foreign_key: :last_build_id, class_name: 'Build'
|
7
|
+
belongs_to :repository
|
8
|
+
has_many :builds
|
9
|
+
has_many :commits
|
10
|
+
has_many :requests
|
11
|
+
|
6
12
|
self.table_name = 'tags'
|
7
13
|
end
|
data/lib/models/token.rb
ADDED
data/lib/models/trial.rb
ADDED
data/lib/models/user.rb
CHANGED
@@ -1,7 +1,39 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'model'
|
4
|
+
require 'models/abuse'
|
5
|
+
require 'models/subscription'
|
6
|
+
require 'models/owner_group'
|
7
|
+
require 'models/trial'
|
8
|
+
require 'models/trial_allowance'
|
9
|
+
require 'models/broadcast'
|
10
|
+
require 'models/star'
|
11
|
+
require 'models/permission'
|
12
|
+
require 'models/token'
|
13
|
+
require 'models/email'
|
14
|
+
require 'models/membership'
|
15
|
+
require 'models/user_beta_feature'
|
4
16
|
|
5
17
|
class User < Model
|
18
|
+
has_many :builds_for_that_this_user_is_owner, as: :owner, class_name: 'Build'
|
19
|
+
has_many :builds_for_that_this_user_is_sender, as: :sender, class_name: 'Build'
|
20
|
+
has_many :repositories, as: :owner
|
21
|
+
has_many :jobs, as: :owner
|
22
|
+
has_many :requests_for_that_this_user_is_owner, as: :owner, class_name: 'Request'
|
23
|
+
has_many :abuses, as: :owner
|
24
|
+
has_many :subscriptions, as: :owner
|
25
|
+
has_many :owner_groups, as: :owner
|
26
|
+
has_many :trials, as: :owner
|
27
|
+
has_many :trial_allowances, as: :creator
|
28
|
+
has_many :broadcasts, as: :recipient
|
29
|
+
has_many :requests_for_that_this_user_is_sender, as: :sender, class_name: 'Request'
|
30
|
+
|
31
|
+
has_many :stars
|
32
|
+
has_many :permissions
|
33
|
+
has_many :tokens
|
34
|
+
has_many :emails
|
35
|
+
has_many :memberships
|
36
|
+
has_many :user_beta_features
|
37
|
+
|
6
38
|
self.table_name = 'users'
|
7
39
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module NullifyDependencies
|
4
|
+
def nullify_dependencies(dependencies_symbols_to_nullify)
|
5
|
+
dependencies_symbols_to_nullify.map do |symbol|
|
6
|
+
dependencies = self.send(symbol) # e.g. build.tags_for_that_this_build_is_last
|
7
|
+
|
8
|
+
dependencies.map do |entry|
|
9
|
+
foreign_key = self.class.reflect_on_association(symbol).foreign_key.to_sym
|
10
|
+
entry.update(foreign_key => nil) # e.g. tag.update(last_build_id: nil)
|
11
|
+
{
|
12
|
+
related_table: entry.class.table_name,
|
13
|
+
foreign_key: foreign_key,
|
14
|
+
parent_id: self.id,
|
15
|
+
related_id: entry.id
|
16
|
+
}
|
17
|
+
end
|
18
|
+
end.flatten
|
19
|
+
end
|
20
|
+
|
21
|
+
def nullify_all_dependencies
|
22
|
+
nullify_dependencies(symbols_of_all_direct_dependencies)
|
23
|
+
end
|
24
|
+
|
25
|
+
def nullify_default_dependencies
|
26
|
+
nullify_dependencies(default_dependencies_symbols_to_nullify)
|
27
|
+
end
|
28
|
+
|
29
|
+
def default_dependencies_symbols_to_nullify
|
30
|
+
self.class.default_dependencies_symbols_to_nullify
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.default_dependencies_symbols_to_nullify
|
34
|
+
raise "self.default_dependencies_symbols_to_nullify not implemented in the #{self.class} class"
|
35
|
+
end
|
36
|
+
|
37
|
+
def default_dependencies_to_nullify
|
38
|
+
default_dependencies_symbols_to_nullify.map do |symbol|
|
39
|
+
self.send(symbol).to_a
|
40
|
+
end.flatten(1)
|
41
|
+
end
|
42
|
+
end
|
data/lib/travis-backup.rb
CHANGED
@@ -3,298 +3,72 @@
|
|
3
3
|
require 'active_support/core_ext/array'
|
4
4
|
require 'active_support/time'
|
5
5
|
require 'config'
|
6
|
+
require 'db_helper'
|
7
|
+
require 'dry_run_reporter'
|
8
|
+
require 'models/abuse'
|
9
|
+
require 'models/annotation'
|
6
10
|
require 'models/repository'
|
7
|
-
require 'models/log'
|
8
11
|
require 'models/branch'
|
9
|
-
require 'models/
|
12
|
+
require 'models/broadcast'
|
13
|
+
require 'models/build'
|
10
14
|
require 'models/commit'
|
11
15
|
require 'models/cron'
|
16
|
+
require 'models/email'
|
17
|
+
require 'models/invoice'
|
18
|
+
require 'models/job'
|
19
|
+
require 'models/log'
|
20
|
+
require 'models/membership'
|
21
|
+
require 'models/message'
|
22
|
+
require 'models/organization'
|
23
|
+
require 'models/owner_group'
|
24
|
+
require 'models/permission'
|
12
25
|
require 'models/pull_request'
|
13
|
-
require 'models/
|
26
|
+
require 'models/queueable_job'
|
27
|
+
require 'models/repository'
|
14
28
|
require 'models/request'
|
29
|
+
require 'models/ssl_key'
|
15
30
|
require 'models/stage'
|
31
|
+
require 'models/star'
|
32
|
+
require 'models/subscription'
|
33
|
+
require 'models/tag'
|
34
|
+
require 'models/token'
|
35
|
+
require 'models/trial_allowance'
|
36
|
+
require 'models/trial'
|
37
|
+
require 'models/user_beta_feature'
|
38
|
+
require 'models/user'
|
39
|
+
require 'backup/move_logs'
|
40
|
+
require 'backup/remove_orphans'
|
41
|
+
require 'backup/load_from_files'
|
42
|
+
require 'backup/remove_specified'
|
16
43
|
|
17
44
|
# main travis-backup class
|
18
45
|
class Backup
|
19
46
|
attr_accessor :config
|
20
|
-
attr_reader :dry_run_report
|
21
47
|
|
22
48
|
def initialize(config_args={})
|
23
49
|
@config = Config.new(config_args)
|
50
|
+
@db_helper = DbHelper.new(@config)
|
24
51
|
|
25
52
|
if @config.dry_run
|
26
|
-
@
|
53
|
+
@dry_run_reporter = DryRunReporter.new
|
27
54
|
end
|
28
|
-
|
29
|
-
connect_db
|
30
55
|
end
|
31
56
|
|
32
|
-
def
|
33
|
-
|
57
|
+
def dry_run_report
|
58
|
+
@dry_run_reporter.report
|
34
59
|
end
|
35
60
|
|
36
61
|
def run(args={})
|
37
|
-
user_id = args[:user_id] || @config.user_id
|
38
|
-
repo_id = args[:repo_id] || @config.repo_id
|
39
|
-
org_id = args[:org_id] || @config.org_id
|
40
|
-
|
41
|
-
if user_id
|
42
|
-
owner_id = user_id
|
43
|
-
owner_type = 'User'
|
44
|
-
elsif org_id
|
45
|
-
owner_id = org_id
|
46
|
-
owner_type = 'Organization'
|
47
|
-
end
|
48
|
-
|
49
62
|
if @config.move_logs
|
50
|
-
|
63
|
+
Backup::MoveLogs.new(@config, @db_helper, @dry_run_reporter).run
|
64
|
+
elsif @config.load_from_files
|
65
|
+
Backup::LoadFromFiles.new(@config, @dry_run_reporter).run
|
51
66
|
elsif @config.remove_orphans
|
52
|
-
|
53
|
-
elsif owner_id
|
54
|
-
process_repos_for_owner(owner_id, owner_type)
|
55
|
-
elsif repo_id
|
56
|
-
process_repo_with_id(repo_id)
|
57
|
-
else
|
58
|
-
process_all_repos
|
59
|
-
end
|
60
|
-
|
61
|
-
print_dry_run_report if @config.dry_run
|
62
|
-
end
|
63
|
-
|
64
|
-
def process_repos_for_owner(owner_id, owner_type)
|
65
|
-
Repository.where('owner_id = ? and owner_type = ?', owner_id, owner_type).order(:id).each do |repository|
|
66
|
-
process_repo(repository)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def process_repo_with_id(repo_id)
|
71
|
-
process_repo(Repository.find(repo_id))
|
72
|
-
end
|
73
|
-
|
74
|
-
def process_all_repos
|
75
|
-
Repository.order(:id).each do |repository|
|
76
|
-
process_repo(repository)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
def print_dry_run_report
|
81
|
-
if @dry_run_report.to_a.map(&:second).flatten.empty?
|
82
|
-
puts 'Dry run active. No data would be removed in normal run.'
|
83
|
-
else
|
84
|
-
puts 'Dry run active. The following data would be removed in normal run:'
|
85
|
-
|
86
|
-
@dry_run_report.to_a.map(&:first).each do |symbol|
|
87
|
-
print_dry_run_report_line(symbol)
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
def print_dry_run_report_line(symbol)
|
93
|
-
puts " - #{symbol}: #{@dry_run_report[symbol].to_json}" if @dry_run_report[symbol].any?
|
94
|
-
end
|
95
|
-
|
96
|
-
def process_repo(repository)
|
97
|
-
process_repo_builds(repository)
|
98
|
-
process_repo_requests(repository)
|
99
|
-
end
|
100
|
-
|
101
|
-
def process_repo_builds(repository) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
102
|
-
threshold = @config.threshold.to_i.months.ago.to_datetime
|
103
|
-
current_build_id = repository.current_build_id || -1
|
104
|
-
repository.builds.where('created_at < ? and id != ?', threshold, current_build_id)
|
105
|
-
.in_groups_of(@config.limit.to_i, false).map do |builds_batch|
|
106
|
-
@config.if_backup ? save_and_destroy_builds_batch(builds_batch, repository) : destroy_builds_batch(builds_batch)
|
107
|
-
end.compact
|
108
|
-
end
|
109
|
-
|
110
|
-
def process_repo_requests(repository)
|
111
|
-
threshold = @config.threshold.to_i.months.ago.to_datetime
|
112
|
-
repository.requests.where('created_at < ?', threshold)
|
113
|
-
.in_groups_of(@config.limit.to_i, false).map do |requests_batch|
|
114
|
-
@config.if_backup ? save_and_destroy_requests_batch(requests_batch, repository) : destroy_requests_batch(requests_batch)
|
115
|
-
end.compact
|
116
|
-
end
|
117
|
-
|
118
|
-
def move_logs
|
119
|
-
return move_logs_dry if config.dry_run
|
120
|
-
|
121
|
-
connect_db(@config.database_url)
|
122
|
-
Log.order(:id).in_groups_of(@config.limit.to_i, false).map do |logs_batch|
|
123
|
-
log_hashes = logs_batch.as_json
|
124
|
-
connect_db(@config.destination_db_url)
|
125
|
-
|
126
|
-
log_hashes.each do |log_hash|
|
127
|
-
new_log = Log.new(log_hash)
|
128
|
-
new_log.save!
|
129
|
-
end
|
130
|
-
|
131
|
-
connect_db(@config.database_url)
|
132
|
-
|
133
|
-
logs_batch.each(&:destroy)
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
def move_logs_dry
|
138
|
-
dry_run_report[:logs].concat(Log.order(:id).map(&:id))
|
139
|
-
end
|
140
|
-
|
141
|
-
def remove_orphans
|
142
|
-
remove_orphans_for_table(Repository, 'repositories', 'builds', 'current_build_id')
|
143
|
-
remove_orphans_for_table(Repository, 'repositories', 'builds', 'last_build_id')
|
144
|
-
remove_orphans_for_table(Build, 'builds', 'repositories', 'repository_id')
|
145
|
-
remove_orphans_for_table(Build, 'builds', 'commits', 'commit_id')
|
146
|
-
remove_orphans_for_table(Build, 'builds', 'requests', 'request_id')
|
147
|
-
remove_orphans_for_table(Build, 'builds', 'pull_requests', 'pull_request_id')
|
148
|
-
remove_orphans_for_table(Build, 'builds', 'branches', 'branch_id')
|
149
|
-
remove_orphans_for_table(Build, 'builds', 'tags', 'tag_id')
|
150
|
-
remove_orphans_for_table(Job, 'jobs', 'repositories', 'repository_id')
|
151
|
-
remove_orphans_for_table(Job, 'jobs', 'commits', 'commit_id')
|
152
|
-
remove_orphans_for_table(Job, 'jobs', 'stages', 'stage_id')
|
153
|
-
remove_orphans_for_table(Branch, 'branches', 'repositories', 'repository_id')
|
154
|
-
remove_orphans_for_table(Branch, 'branches', 'builds', 'last_build_id')
|
155
|
-
remove_orphans_for_table(Tag, 'tags', 'repositories', 'repository_id')
|
156
|
-
remove_orphans_for_table(Tag, 'tags', 'builds', 'last_build_id')
|
157
|
-
remove_orphans_for_table(Commit, 'commits', 'repositories', 'repository_id')
|
158
|
-
remove_orphans_for_table(Commit, 'commits', 'branches', 'branch_id')
|
159
|
-
remove_orphans_for_table(Commit, 'commits', 'tags', 'tag_id')
|
160
|
-
remove_orphans_for_table(Cron, 'crons', 'branches', 'branch_id')
|
161
|
-
remove_orphans_for_table(PullRequest, 'pull_requests', 'repositories', 'repository_id')
|
162
|
-
remove_orphans_for_table(SslKey, 'ssl_keys', 'repositories', 'repository_id')
|
163
|
-
remove_orphans_for_table(Request, 'requests', 'commits', 'commit_id')
|
164
|
-
remove_orphans_for_table(Request, 'requests', 'pull_requests', 'pull_request_id')
|
165
|
-
remove_orphans_for_table(Request, 'requests', 'branches', 'branch_id')
|
166
|
-
remove_orphans_for_table(Request, 'requests', 'tags', 'tag_id')
|
167
|
-
remove_orphans_for_table(Stage, 'stages', 'builds', 'build_id')
|
168
|
-
end
|
169
|
-
|
170
|
-
def remove_orphans_for_table(model_class, table_a_name, table_b_name, fk_name)
|
171
|
-
for_delete = model_class.find_by_sql(%{
|
172
|
-
select a.*
|
173
|
-
from #{table_a_name} a
|
174
|
-
left join #{table_b_name} b
|
175
|
-
on a.#{fk_name} = b.id
|
176
|
-
where
|
177
|
-
a.#{fk_name} is not null
|
178
|
-
and b.id is null;
|
179
|
-
})
|
180
|
-
|
181
|
-
if config.dry_run
|
182
|
-
key = table_a_name.to_sym
|
183
|
-
dry_run_report[key] = [] if dry_run_report[key].nil?
|
184
|
-
dry_run_report[key].concat(for_delete.map(&:id))
|
185
|
-
dry_run_report[key].uniq!
|
67
|
+
Backup::RemoveOrphans.new(@config, @dry_run_reporter).run
|
186
68
|
else
|
187
|
-
|
188
|
-
end
|
189
|
-
end
|
190
|
-
|
191
|
-
private
|
192
|
-
|
193
|
-
def save_and_destroy_builds_batch(builds_batch, repository)
|
194
|
-
builds_export = export_builds(builds_batch)
|
195
|
-
file_name = "repository_#{repository.id}_builds_#{builds_batch.first.id}-#{builds_batch.last.id}.json"
|
196
|
-
pretty_json = JSON.pretty_generate(builds_export)
|
197
|
-
if save_file(file_name, pretty_json)
|
198
|
-
destroy_builds_batch(builds_batch)
|
69
|
+
Backup::RemoveSpecified.new(@config, @dry_run_reporter).run(args)
|
199
70
|
end
|
200
|
-
builds_export
|
201
|
-
end
|
202
|
-
|
203
|
-
def destroy_builds_batch(builds_batch)
|
204
|
-
return destroy_builds_batch_dry(builds_batch) if @config.dry_run
|
205
|
-
|
206
|
-
builds_batch.each(&:destroy)
|
207
|
-
end
|
208
71
|
|
209
|
-
|
210
|
-
@dry_run_report[:builds].concat(builds_batch.map(&:id))
|
211
|
-
|
212
|
-
jobs = builds_batch.map do |build|
|
213
|
-
build.jobs.map(&:id) || []
|
214
|
-
end.flatten
|
215
|
-
|
216
|
-
@dry_run_report[:jobs].concat(jobs)
|
217
|
-
|
218
|
-
logs = builds_batch.map do |build|
|
219
|
-
build.jobs.map do |job|
|
220
|
-
job.logs.map(&:id) || []
|
221
|
-
end.flatten || []
|
222
|
-
end.flatten
|
223
|
-
|
224
|
-
@dry_run_report[:logs].concat(logs)
|
225
|
-
end
|
226
|
-
|
227
|
-
def save_and_destroy_requests_batch(requests_batch, repository)
|
228
|
-
requests_export = export_requests(requests_batch)
|
229
|
-
file_name = "repository_#{repository.id}_requests_#{requests_batch.first.id}-#{requests_batch.last.id}.json"
|
230
|
-
pretty_json = JSON.pretty_generate(requests_export)
|
231
|
-
if save_file(file_name, pretty_json)
|
232
|
-
destroy_requests_batch(requests_batch)
|
233
|
-
end
|
234
|
-
requests_export
|
235
|
-
end
|
236
|
-
|
237
|
-
def destroy_requests_batch(requests_batch)
|
238
|
-
return destroy_requests_batch_dry(requests_batch) if @config.dry_run
|
239
|
-
|
240
|
-
requests_batch.each(&:destroy)
|
241
|
-
end
|
242
|
-
|
243
|
-
def destroy_requests_batch_dry(requests_batch)
|
244
|
-
@dry_run_report[:requests].concat(requests_batch.map(&:id))
|
245
|
-
end
|
246
|
-
|
247
|
-
def save_file(file_name, content) # rubocop:disable Metrics/MethodLength
|
248
|
-
return true if @config.dry_run
|
249
|
-
|
250
|
-
saved = false
|
251
|
-
begin
|
252
|
-
unless File.directory?(@config.files_location)
|
253
|
-
FileUtils.mkdir_p(@config.files_location)
|
254
|
-
end
|
255
|
-
|
256
|
-
File.open(file_path(file_name), 'w') do |file|
|
257
|
-
file.write(content)
|
258
|
-
file.close
|
259
|
-
saved = true
|
260
|
-
end
|
261
|
-
rescue => e
|
262
|
-
print "Failed to save #{file_name}, error: #{e.inspect}\n"
|
263
|
-
end
|
264
|
-
saved
|
265
|
-
end
|
266
|
-
|
267
|
-
def file_path(file_name)
|
268
|
-
"#{@config.files_location}/#{file_name}"
|
269
|
-
end
|
270
|
-
|
271
|
-
def export_builds(builds)
|
272
|
-
builds.map do |build|
|
273
|
-
build_export = build.attributes
|
274
|
-
build_export[:jobs] = export_jobs(build.jobs)
|
275
|
-
|
276
|
-
build_export
|
277
|
-
end
|
278
|
-
end
|
279
|
-
|
280
|
-
def export_jobs(jobs)
|
281
|
-
jobs.map do |job|
|
282
|
-
job_export = job.attributes
|
283
|
-
job_export[:logs] = export_logs(job.logs)
|
284
|
-
|
285
|
-
job_export
|
286
|
-
end
|
287
|
-
end
|
288
|
-
|
289
|
-
def export_logs(logs)
|
290
|
-
logs.map do |log|
|
291
|
-
log.attributes
|
292
|
-
end
|
293
|
-
end
|
294
|
-
|
295
|
-
def export_requests(requests)
|
296
|
-
requests.map do |request|
|
297
|
-
request.attributes
|
298
|
-
end
|
72
|
+
@dry_run_reporter.print_report if @config.dry_run
|
299
73
|
end
|
300
74
|
end
|
data/travis-backup.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'travis-backup'
|
3
|
-
s.version = '0.
|
3
|
+
s.version = '0.3.0'
|
4
4
|
s.summary = 'Travis CI backup tool'
|
5
5
|
s.authors = ['Karol Selak']
|
6
6
|
s.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
@@ -26,4 +26,5 @@ Gem::Specification.new do |s|
|
|
26
26
|
s.add_development_dependency 'listen'
|
27
27
|
s.add_development_dependency 'rubocop', '~> 0.75.1'
|
28
28
|
s.add_development_dependency 'rubocop-rspec'
|
29
|
+
s.add_development_dependency 'database_cleaner-active_record'
|
29
30
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: travis-backup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Karol Selak
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-09
|
11
|
+
date: 2021-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -192,24 +192,37 @@ dependencies:
|
|
192
192
|
- - ">="
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: '0'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: database_cleaner-active_record
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
202
|
+
type: :development
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - ">="
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0'
|
195
209
|
description:
|
196
210
|
email:
|
197
211
|
executables:
|
198
212
|
- setup
|
199
|
-
-
|
213
|
+
- console
|
214
|
+
- rake
|
215
|
+
- travis_backup
|
200
216
|
- spring
|
201
|
-
-
|
217
|
+
- rails
|
202
218
|
- bundle
|
203
|
-
-
|
204
|
-
- rake
|
205
|
-
- console
|
219
|
+
- yarn
|
206
220
|
extensions: []
|
207
221
|
extra_rdoc_files: []
|
208
222
|
files:
|
209
223
|
- ".gitignore"
|
210
224
|
- ".travis.yml"
|
211
225
|
- Gemfile
|
212
|
-
- Gemfile.lock
|
213
226
|
- README.md
|
214
227
|
- Rakefile
|
215
228
|
- bin/bundle
|
@@ -247,22 +260,53 @@ files:
|
|
247
260
|
- config/spring.rb
|
248
261
|
- db/schema.sql
|
249
262
|
- dump/.keep
|
263
|
+
- lib/backup/load_from_files.rb
|
264
|
+
- lib/backup/move_logs.rb
|
265
|
+
- lib/backup/remove_orphans.rb
|
266
|
+
- lib/backup/remove_specified.rb
|
267
|
+
- lib/backup/remove_specified/remove_heavy_data.rb
|
268
|
+
- lib/backup/remove_specified/remove_with_all_dependencies.rb
|
269
|
+
- lib/backup/remove_specified/shared.rb
|
270
|
+
- lib/backup/save_file.rb
|
271
|
+
- lib/backup/save_id_hash_to_file.rb
|
272
|
+
- lib/backup/save_nullified_rels_to_file.rb
|
250
273
|
- lib/config.rb
|
274
|
+
- lib/db_helper.rb
|
275
|
+
- lib/dry_run_reporter.rb
|
276
|
+
- lib/id_hash.rb
|
277
|
+
- lib/ids_of_all_dependencies.rb
|
278
|
+
- lib/model.rb
|
279
|
+
- lib/models/abuse.rb
|
280
|
+
- lib/models/annotation.rb
|
251
281
|
- lib/models/branch.rb
|
282
|
+
- lib/models/broadcast.rb
|
252
283
|
- lib/models/build.rb
|
253
284
|
- lib/models/commit.rb
|
254
285
|
- lib/models/cron.rb
|
286
|
+
- lib/models/email.rb
|
287
|
+
- lib/models/invoice.rb
|
255
288
|
- lib/models/job.rb
|
256
289
|
- lib/models/log.rb
|
257
|
-
- lib/models/
|
290
|
+
- lib/models/membership.rb
|
291
|
+
- lib/models/message.rb
|
258
292
|
- lib/models/organization.rb
|
293
|
+
- lib/models/owner_group.rb
|
294
|
+
- lib/models/permission.rb
|
259
295
|
- lib/models/pull_request.rb
|
296
|
+
- lib/models/queueable_job.rb
|
260
297
|
- lib/models/repository.rb
|
261
298
|
- lib/models/request.rb
|
262
299
|
- lib/models/ssl_key.rb
|
263
300
|
- lib/models/stage.rb
|
301
|
+
- lib/models/star.rb
|
302
|
+
- lib/models/subscription.rb
|
264
303
|
- lib/models/tag.rb
|
304
|
+
- lib/models/token.rb
|
305
|
+
- lib/models/trial.rb
|
306
|
+
- lib/models/trial_allowance.rb
|
265
307
|
- lib/models/user.rb
|
308
|
+
- lib/models/user_beta_feature.rb
|
309
|
+
- lib/nullify_dependencies.rb
|
266
310
|
- lib/travis-backup.rb
|
267
311
|
- log/.keep
|
268
312
|
- package.json
|