rtbackup 0.1.21

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ServerBackups
4
+ VERSION = '0.1.21'
5
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ServerBackups
4
+ class WebsiteBackup < BackupBase
5
+ SNAPSHOT_PATH = Pathname('~/.var.www.backup.tar.snapshot.bin').expand_path
6
+
7
+ def restore(time); end
8
+
9
+ def backup_filename
10
+ "#{self.class.name.demodulize.underscore}.#{backup_type}.#{timestamp}.tgz"
11
+ end
12
+
13
+ def create_archive_command
14
+ <<-CMD
15
+ tar --create -C '#{config.web_root}' --listed-incremental=#{SNAPSHOT_PATH} --gzip \
16
+ --no-check-device \
17
+ #{'--level=0' unless incremental?} \
18
+ --file=#{backup_path} #{config.web_root}
19
+ CMD
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'English'
4
+
5
+ module ServerBackups
6
+ class WebsiteRestore < RestoreBase
7
+ def files_to_restore
8
+ [all_files.full_backup_for(restore_point),
9
+ *all_files.incremental_backups_for(restore_point)]
10
+ end
11
+
12
+ def do_restore
13
+ logger.warn "Moving old #{config.web_root} ---->>> #{config.web_root}.backup\n" \
14
+ 'You will have to delete it yourself.'
15
+ make_copy_of_existing_web_root
16
+ files_to_restore.each_with_index { |file, index| restore_file(file, index) }
17
+ end
18
+
19
+ private
20
+
21
+ def make_copy_of_existing_web_root
22
+ FileUtils.mv config.web_root, "#{config.web_root}.backup" \
23
+ if File.exist?(config.web_root)
24
+ FileUtils.mkdir config.web_root
25
+ end
26
+
27
+ def s3_prefix
28
+ File.join(config.prefix, 'website_backup', '/')
29
+ end
30
+
31
+ def restore_file(s3object, ordinal)
32
+ local_filename = File.join(working_dir, "#{ordinal}.tgz")
33
+ s3object.get response_target: local_filename
34
+ system untar_command(local_filename)
35
+ unless last_command_succeeded?
36
+ raise BackupCreationError.new("Received #{$CHILD_STATUS} from tar command.",
37
+ self.class, 'restore')
38
+ end
39
+ logger.info "Restored #{File.basename(s3object.key)}"
40
+ end
41
+
42
+ def untar_command(local_filename)
43
+ <<-CMD
44
+ tar zxp -C '/' --listed-incremental=/dev/null \
45
+ --no-check-device \
46
+ --file=#{local_filename}
47
+ CMD
48
+ end
49
+ end
50
+ end
data/rtbackup.gemspec ADDED
@@ -0,0 +1,45 @@
1
+
2
+ # frozen_string_literal: true
3
+
4
+ lib = File.expand_path('lib', __dir__)
5
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
6
+ require 'server_backups/version'
7
+
8
+ Gem::Specification.new do |spec|
9
+ spec.name = 'rtbackup'
10
+ spec.version = ServerBackups::VERSION
11
+ spec.authors = ['Tyler Gannon']
12
+ spec.email = ['tgannon@gmail.com']
13
+
14
+ spec.summary = 'For taking backups of servers.'
15
+ spec.description = 'For taking backups of servers.'
16
+ spec.homepage = 'https://github.com/tylergannon/server_backups'
17
+ spec.license = 'MIT'
18
+
19
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
20
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
21
+ if spec.respond_to?(:metadata)
22
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
23
+ else
24
+ raise 'RubyGems 2.0 or newer is required to protect against ' \
25
+ 'public gem pushes.'
26
+ end
27
+
28
+ spec.add_dependency 'activesupport', '~> 5.1'
29
+ spec.add_dependency 'aws-sdk-s3', '~> 1.8'
30
+ spec.add_dependency 'main', '~> 6.2'
31
+ spec.add_dependency 'slack-notifier', '~> 2.3'
32
+
33
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
34
+ f.match(%r{^(test|spec|features)/})
35
+ end
36
+ spec.bindir = 'bin'
37
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
38
+ spec.require_paths = ['lib']
39
+
40
+ spec.add_development_dependency 'bundler', '~> 1.16'
41
+ spec.add_development_dependency 'rake', '~> 10.5'
42
+ spec.add_development_dependency 'rspec', '~> 3.0'
43
+ spec.add_development_dependency 'vcr', '~> 4.0'
44
+ spec.add_development_dependency 'webmock', '~> 3.3'
45
+ end
metadata ADDED
@@ -0,0 +1,203 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rtbackup
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.21
5
+ platform: ruby
6
+ authors:
7
+ - Tyler Gannon
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-06-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '5.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '5.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: aws-sdk-s3
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.8'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.8'
41
+ - !ruby/object:Gem::Dependency
42
+ name: main
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '6.2'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '6.2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: slack-notifier
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.3'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.3'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.16'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.16'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '10.5'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '10.5'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: vcr
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '4.0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '4.0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: webmock
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '3.3'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '3.3'
139
+ description: For taking backups of servers.
140
+ email:
141
+ - tgannon@gmail.com
142
+ executables:
143
+ - rtbackup
144
+ extensions: []
145
+ extra_rdoc_files: []
146
+ files:
147
+ - ".gitignore"
148
+ - ".rspec"
149
+ - ".rubocop.yml"
150
+ - ".rubocop_todo.yml"
151
+ - ".ruby-version"
152
+ - ".travis.yml"
153
+ - CODE_OF_CONDUCT.md
154
+ - Gemfile
155
+ - Gemfile.lock
156
+ - LICENSE.txt
157
+ - README.md
158
+ - Rakefile
159
+ - backup_conf.sample.yml
160
+ - bin/rtbackup
161
+ - crontab.txt
162
+ - incremental_snapshot
163
+ - lib/server_backups.rb
164
+ - lib/server_backups/backup_base.rb
165
+ - lib/server_backups/config.rb
166
+ - lib/server_backups/errors.rb
167
+ - lib/server_backups/mysql_backup.rb
168
+ - lib/server_backups/mysql_incremental_backup.rb
169
+ - lib/server_backups/mysql_restore.rb
170
+ - lib/server_backups/notifier.rb
171
+ - lib/server_backups/ordered_backup_file_collection.rb
172
+ - lib/server_backups/restore_base.rb
173
+ - lib/server_backups/s3.rb
174
+ - lib/server_backups/version.rb
175
+ - lib/server_backups/website_backup.rb
176
+ - lib/server_backups/website_restore.rb
177
+ - rtbackup.gemspec
178
+ homepage: https://github.com/tylergannon/server_backups
179
+ licenses:
180
+ - MIT
181
+ metadata:
182
+ allowed_push_host: https://rubygems.org
183
+ post_install_message:
184
+ rdoc_options: []
185
+ require_paths:
186
+ - lib
187
+ required_ruby_version: !ruby/object:Gem::Requirement
188
+ requirements:
189
+ - - ">="
190
+ - !ruby/object:Gem::Version
191
+ version: '0'
192
+ required_rubygems_version: !ruby/object:Gem::Requirement
193
+ requirements:
194
+ - - ">="
195
+ - !ruby/object:Gem::Version
196
+ version: '0'
197
+ requirements: []
198
+ rubyforge_project:
199
+ rubygems_version: 2.5.1
200
+ signing_key:
201
+ specification_version: 4
202
+ summary: For taking backups of servers.
203
+ test_files: []