backup-gundua 2.3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +5 -0
- data/CHANGELOG +77 -0
- data/LICENSE +9 -0
- data/README.textile +175 -0
- data/Rakefile +69 -0
- data/VERSION +1 -0
- data/backup.gemspec +123 -0
- data/bin/backup +124 -0
- data/generators/backup/backup_generator.rb +72 -0
- data/generators/backup/templates/config/backup.rb +202 -0
- data/generators/backup/templates/migrations/create_backup_tables.rb +18 -0
- data/generators/backup/templates/tasks/backup.rake +71 -0
- data/generators/backup_update/backup_update_generator.rb +50 -0
- data/generators/backup_update/templates/migrations/update_backup_tables.rb +27 -0
- data/lib/backup/adapters/archive.rb +34 -0
- data/lib/backup/adapters/base.rb +113 -0
- data/lib/backup/adapters/custom.rb +41 -0
- data/lib/backup/adapters/mysql.rb +54 -0
- data/lib/backup/adapters/postgresql.rb +56 -0
- data/lib/backup/adapters/sqlite.rb +25 -0
- data/lib/backup/command_helper.rb +11 -0
- data/lib/backup/configuration/adapter.rb +21 -0
- data/lib/backup/configuration/adapter_options.rb +8 -0
- data/lib/backup/configuration/attributes.rb +19 -0
- data/lib/backup/configuration/base.rb +55 -0
- data/lib/backup/configuration/helpers.rb +24 -0
- data/lib/backup/configuration/mail.rb +20 -0
- data/lib/backup/configuration/smtp.rb +8 -0
- data/lib/backup/configuration/storage.rb +8 -0
- data/lib/backup/connection/s3.rb +85 -0
- data/lib/backup/environment/base.rb +12 -0
- data/lib/backup/environment/rails.rb +17 -0
- data/lib/backup/environment/unix.rb +94 -0
- data/lib/backup/mail/base.rb +93 -0
- data/lib/backup/mail/mail.txt +7 -0
- data/lib/backup/record/base.rb +65 -0
- data/lib/backup/record/ftp.rb +37 -0
- data/lib/backup/record/local.rb +26 -0
- data/lib/backup/record/s3.rb +24 -0
- data/lib/backup/record/scp.rb +31 -0
- data/lib/backup/record/sftp.rb +36 -0
- data/lib/backup/storage/ftp.rb +36 -0
- data/lib/backup/storage/local.rb +24 -0
- data/lib/backup/storage/s3.rb +14 -0
- data/lib/backup/storage/scp.rb +28 -0
- data/lib/backup/storage/sftp.rb +29 -0
- data/lib/backup.rb +118 -0
- data/setup/backup.rb +202 -0
- data/setup/backup.sqlite3 +0 -0
- data/spec/configuration/attributes_spec.rb +35 -0
- metadata +185 -0
data/.document
ADDED
data/CHANGELOG
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
=== 2.?.? ====================================
|
2
|
+
|
3
|
+
- Added Storage Method: Local
|
4
|
+
- Added Adapter: SQLite
|
5
|
+
- exclude option added for Archive Adapter
|
6
|
+
- Internal cleanup
|
7
|
+
- Will try to automatically determine the path to mysqldump and pg_dump utilities
|
8
|
+
- Added spec/tests
|
9
|
+
|
10
|
+
MINOR UPDATE
|
11
|
+
=== 2.3.1 ======================================
|
12
|
+
|
13
|
+
- Added Feature: Email notifications
|
14
|
+
|
15
|
+
|
16
|
+
PATCH
|
17
|
+
=== 2.3.0.3 ====================================
|
18
|
+
|
19
|
+
- Small bug was patched. Error would occur when a list of triggers should be shown
|
20
|
+
|
21
|
+
|
22
|
+
BIG UPDATE
|
23
|
+
=== 2.3.0 ====================================
|
24
|
+
|
25
|
+
- Backup became independent of Ruby on Rails
|
26
|
+
- Backup now supports multiple environments: Rails and Unix
|
27
|
+
- Backup is now executable through the command-line when using the Unix environment
|
28
|
+
|
29
|
+
|
30
|
+
SMALL FEATURE UPDATE
|
31
|
+
=== 2.2.1 ====================================
|
32
|
+
|
33
|
+
- use_ssl option added for S3 Storage Method
|
34
|
+
- additional_options option added for MySQL and PostgreSQL Adapters
|
35
|
+
|
36
|
+
|
37
|
+
PRETTY BIG UPDATE
|
38
|
+
=== 2.2.0 ====================================
|
39
|
+
|
40
|
+
- Added Storage Methods: FTP and SFTP
|
41
|
+
- Added Adapters: PostgreSQL and Custom
|
42
|
+
- Added more options to the MySQL Adapter
|
43
|
+
- A couple of bug fixes
|
44
|
+
|
45
|
+
|
46
|
+
MINOR UPDATE
|
47
|
+
=== 2.1.2 ====================================
|
48
|
+
|
49
|
+
- The backup generator will now provide you with a step-by-step guide to getting up and running
|
50
|
+
- Updated the generator itself
|
51
|
+
- Removed SQLite3 dependencies
|
52
|
+
|
53
|
+
|
54
|
+
2 TABLES 2 1
|
55
|
+
=== 2.1.1 ====================================
|
56
|
+
|
57
|
+
- Backup will from now on only utilize one table, instead of one for each storage method
|
58
|
+
- Still backwards compatible to 2.1.0
|
59
|
+
|
60
|
+
|
61
|
+
FIXED A CRUCIAL BUG
|
62
|
+
=== 2.1.0 ====================================
|
63
|
+
|
64
|
+
- Problem with Backup::Record. It tried to connect to the SQLite3 database.
|
65
|
+
|
66
|
+
|
67
|
+
MAJOR RELEASE
|
68
|
+
=== 2.0.0 ====================================
|
69
|
+
|
70
|
+
- Should be a lot more backwards compatible with every update I do.
|
71
|
+
- Does not depend on the separate local SQLite3 file any longer.
|
72
|
+
- Will provide a db migration file for your Rails Application to store backup record data in.
|
73
|
+
- Does not use YAML files to do configuration any longer.
|
74
|
+
- Uses a SINGLE ruby file for "all" configuration (config/backup.rb) using elegant block notations!
|
75
|
+
- Uses a SINGLE rake task to handle the initialization of any backup setting.
|
76
|
+
- Can now configure an unlimited amount of customizable backup settings and run them each "individually"!
|
77
|
+
- HIGHLY IMPROVED USABILITY!
|
data/LICENSE
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
Copyright (c) 2009 Michael van Rooijen - Final Creation (http://final-creation.com)
|
2
|
+
|
3
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
4
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
5
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
6
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
7
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
8
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
9
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.textile
ADDED
@@ -0,0 +1,175 @@
|
|
1
|
+
h1. Backup
|
2
|
+
|
3
|
+
h2. A Backup Ruby Gem
|
4
|
+
|
5
|
+
Backup is a Ruby Gem written for Unix and Rails environments. It can be used both with and without the Ruby on Rails framework! This gem offers a quick and simple solution to backing up databases such as MySQL/PostgreSQL and Files/Folders. All backups can be transferred to Amazon S3 or any remote server you have access to, using either SCP, SFTP or regular FTP. Backup handles Compression, Archiving, Encryption, Backup Cleaning (Cycling) and supports Email Notifications.
|
6
|
+
|
7
|
+
h2. Authors/Maintainers
|
8
|
+
|
9
|
+
* "Meskyanichi - Michael van Rooijen":http://github.com/meskyanichi
|
10
|
+
* "Fernandoluizao - Fernando Migliorini Luizão":http://github.com/fernandoluizao
|
11
|
+
|
12
|
+
|
13
|
+
h2. Backup's Current Capabilities
|
14
|
+
|
15
|
+
h3. Storage Methods
|
16
|
+
|
17
|
+
* Amazon S3
|
18
|
+
* Remote Server (Available Protocols: SCP, SFTP, FTP)
|
19
|
+
* Local server (Example Locations: Another Hard Drive, Network path) *(coming in the next gem release)*
|
20
|
+
|
21
|
+
h3. Adapters
|
22
|
+
|
23
|
+
* MySQL
|
24
|
+
* SQLite *(in the next gem release)*
|
25
|
+
* PostgreSQL
|
26
|
+
* Archive (Any files and/or folders)
|
27
|
+
* Custom (Anything you can produce using the command line)
|
28
|
+
|
29
|
+
h3. Archiving
|
30
|
+
|
31
|
+
Handles archiving for the *Archive* and *Custom* adapters.
|
32
|
+
|
33
|
+
h3. Encryption
|
34
|
+
|
35
|
+
Handles encryption of *all* backups for *any* adapter.
|
36
|
+
To decrypt a "Backup encrypted file" you can use Backup's built-in utility command:
|
37
|
+
|
38
|
+
bc. sudo backup --decrypt /path/to/encrypted/file.enc
|
39
|
+
|
40
|
+
h3. Backup Cleaning
|
41
|
+
|
42
|
+
With Backup you can very easily specify how many backups you would like to have stored (per backup procedure!) on your Amazon S3, Remote or Local server. When the limit you specify gets exceeded, the oldest backup will automatically be cleaned up.
|
43
|
+
|
44
|
+
h3. Email Notifications
|
45
|
+
|
46
|
+
You will be able to specify whether you would like to be notified by email when a backup successfully been stored.
|
47
|
+
Simply fill in the email configuration block and set "notify" to true inside the backup procedure you would like to be notified of.
|
48
|
+
|
49
|
+
h3. Quick Example of a Single Backup Setting/Procedure inside the Backup Configuration File
|
50
|
+
|
51
|
+
bc. backup 'mysql-backup-s3' do
|
52
|
+
adapter :mysql do
|
53
|
+
user 'user'
|
54
|
+
password 'password'
|
55
|
+
database 'database'
|
56
|
+
end
|
57
|
+
storage :s3 do
|
58
|
+
access_key_id 'access_key_id'
|
59
|
+
secret_access_key 'secret_access_key'
|
60
|
+
bucket '/bucket/backups/mysql/'
|
61
|
+
use_ssl true
|
62
|
+
end
|
63
|
+
keep_backups 25
|
64
|
+
encrypt_with_password 'my_password'
|
65
|
+
notify true
|
66
|
+
end
|
67
|
+
|
68
|
+
Everything above should be pretty straightforward, so now, using the "trigger" we specified between
|
69
|
+
the *backup* and *do* you can execute this backup procedure like so:
|
70
|
+
|
71
|
+
*Rails Environment*
|
72
|
+
|
73
|
+
bc. rake backup:run trigger=mysql-backup-s3
|
74
|
+
|
75
|
+
*Unix Environment*
|
76
|
+
|
77
|
+
bc. sudo backup --run mysql-backup-s3
|
78
|
+
|
79
|
+
That's it. This was a simple example of how it works.
|
80
|
+
|
81
|
+
|
82
|
+
h2. Interested in trying out Backup?
|
83
|
+
|
84
|
+
|
85
|
+
h3. Getting started with Backup for the *Unix Environment*
|
86
|
+
|
87
|
+
"http://wiki.github.com/meskyanichi/backup/getting-started-unix":http://wiki.github.com/meskyanichi/backup/getting-started-unix
|
88
|
+
|
89
|
+
|
90
|
+
h3. Getting started with Backup for the *Rails Environment*
|
91
|
+
|
92
|
+
"http://wiki.github.com/meskyanichi/backup/getting-started-ruby-on-rails":http://wiki.github.com/meskyanichi/backup/getting-started-ruby-on-rails
|
93
|
+
|
94
|
+
|
95
|
+
h3. Production Mode *RAILS_ENV*
|
96
|
+
|
97
|
+
"http://wiki.github.com/meskyanichi/backup/production-mode":http://wiki.github.com/meskyanichi/backup/production-mode
|
98
|
+
|
99
|
+
|
100
|
+
h3. Encrypting and Decrypting
|
101
|
+
|
102
|
+
"http://wiki.github.com/meskyanichi/backup/encrypting-and-decrypting":http://wiki.github.com/meskyanichi/backup/encrypting-and-decrypting
|
103
|
+
|
104
|
+
|
105
|
+
h3. Backup Configuration File (All Adapters, Storage Methods, Mail Settings and Options)
|
106
|
+
|
107
|
+
"http://wiki.github.com/meskyanichi/backup/configuration-file":http://wiki.github.com/meskyanichi/backup/configuration-file
|
108
|
+
|
109
|
+
|
110
|
+
h3. Unix Utility Commands and Rails Rake Tasks
|
111
|
+
|
112
|
+
"http://wiki.github.com/meskyanichi/backup/utility-commands":http://wiki.github.com/meskyanichi/backup/utility-commands
|
113
|
+
|
114
|
+
"http://wiki.github.com/meskyanichi/backup/rake-tasks":http://wiki.github.com/meskyanichi/backup/rake-tasks
|
115
|
+
|
116
|
+
|
117
|
+
h3. Automatic Backups
|
118
|
+
|
119
|
+
"http://wiki.github.com/meskyanichi/backup/automatic-backups":http://wiki.github.com/meskyanichi/backup/automatic-backups
|
120
|
+
|
121
|
+
|
122
|
+
h3. Capistrano Recipes
|
123
|
+
|
124
|
+
"http://wiki.github.com/meskyanichi/backup/capistrano-recipes":http://wiki.github.com/meskyanichi/backup/capistrano-recipes
|
125
|
+
|
126
|
+
|
127
|
+
h3. Capistrano, Whenever!
|
128
|
+
|
129
|
+
"http://wiki.github.com/meskyanichi/backup/capistrano-whenever":http://wiki.github.com/meskyanichi/backup/capistrano-whenever
|
130
|
+
|
131
|
+
|
132
|
+
h3. Understanding "The Backup Database"
|
133
|
+
|
134
|
+
"http://wiki.github.com/meskyanichi/backup/the-backup-database":http://wiki.github.com/meskyanichi/backup/the-backup-database
|
135
|
+
|
136
|
+
|
137
|
+
h3. Trouble Shooting
|
138
|
+
|
139
|
+
"http://wiki.github.com/meskyanichi/backup/troubleshooting":http://wiki.github.com/meskyanichi/backup/troubleshooting
|
140
|
+
|
141
|
+
|
142
|
+
h3. Requirements
|
143
|
+
|
144
|
+
"http://wiki.github.com/meskyanichi/backup/requirements":http://wiki.github.com/meskyanichi/backup/requirements
|
145
|
+
|
146
|
+
|
147
|
+
h3. Resources
|
148
|
+
|
149
|
+
"http://wiki.github.com/meskyanichi/backup/resources":http://wiki.github.com/meskyanichi/backup/resources
|
150
|
+
|
151
|
+
|
152
|
+
h3. Requests
|
153
|
+
|
154
|
+
If anyone has any requests, please send us a message or post it on the issues page!
|
155
|
+
|
156
|
+
|
157
|
+
h3. Suggestions?
|
158
|
+
|
159
|
+
Send us a message! Fork the project!
|
160
|
+
|
161
|
+
|
162
|
+
h3. Found a Bug?
|
163
|
+
|
164
|
+
"http://github.com/meskyanichi/backup/issues":http://github.com/meskyanichi/backup/issues
|
165
|
+
|
166
|
+
|
167
|
+
h3. Contributors
|
168
|
+
|
169
|
+
List of people that forked and added stuff!
|
170
|
+
|
171
|
+
* "dtrueman":http://github.com/dtrueman
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
_Michael van Rooijen | Final Creation. ("http://final-creation.com":http://final-creation.com)_
|
data/Rakefile
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "backup"
|
8
|
+
gem.summary = %Q{Backup is a Ruby Gem that simplifies making backups for databases, files and folders.}
|
9
|
+
gem.description = %Q{
|
10
|
+
Backup is a Ruby Gem written for Unix and Rails environments. It can be used both with and without the
|
11
|
+
Ruby on Rails framework! This gem offers a quick and simple solution to backing up databases such as
|
12
|
+
MySQL/PostgreSQL and Files/Folders. All backups can be transferred to Amazon S3 or any remote server you
|
13
|
+
have access to, using either SCP, SFTP or regular FTP. Backup handles Compression, Archiving, Encryption,
|
14
|
+
Backup Cleaning (Cycling) and supports Email Notifications.
|
15
|
+
}
|
16
|
+
|
17
|
+
gem.email = "meskyanichi@gmail.com"
|
18
|
+
gem.homepage = "http://final-creation.com/open-source"
|
19
|
+
gem.authors = ["Michael van Rooijen", "Fernando Migliorini Luizão"]
|
20
|
+
gem.add_dependency "aws-s3", ">= 0.6.2"
|
21
|
+
gem.add_dependency "net-ssh", ">= 2.0.15"
|
22
|
+
gem.add_dependency "net-scp", ">= 1.0.2"
|
23
|
+
gem.add_dependency "net-sftp", ">= 2.0.4"
|
24
|
+
gem.add_dependency "activerecord", ">= 2.3.5"
|
25
|
+
gem.add_dependency "sqlite3-ruby", ">= 1.2.5"
|
26
|
+
gem.add_dependency "hirb", ">= 0.2.9"
|
27
|
+
gem.add_dependency "pony", ">= 0.5"
|
28
|
+
|
29
|
+
end
|
30
|
+
rescue LoadError
|
31
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
32
|
+
end
|
33
|
+
|
34
|
+
require 'spec/rake/spectask'
|
35
|
+
Spec::Rake::SpecTask.new do |t|
|
36
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
37
|
+
t.spec_opts = %w(-fp --color)
|
38
|
+
end
|
39
|
+
|
40
|
+
begin
|
41
|
+
require 'rcov/rcovtask'
|
42
|
+
Rcov::RcovTask.new do |test|
|
43
|
+
test.libs << 'test'
|
44
|
+
test.pattern = 'test/**/*_test.rb'
|
45
|
+
test.verbose = true
|
46
|
+
end
|
47
|
+
rescue LoadError
|
48
|
+
task :rcov do
|
49
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
task :test => :check_dependencies
|
54
|
+
|
55
|
+
task :default => :spec
|
56
|
+
|
57
|
+
require 'rake/rdoctask'
|
58
|
+
Rake::RDocTask.new do |rdoc|
|
59
|
+
if File.exist?('VERSION')
|
60
|
+
version = File.read('VERSION')
|
61
|
+
else
|
62
|
+
version = ""
|
63
|
+
end
|
64
|
+
|
65
|
+
rdoc.rdoc_dir = 'rdoc'
|
66
|
+
rdoc.title = "backup #{version}"
|
67
|
+
rdoc.rdoc_files.include('README*')
|
68
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
69
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.3.1
|
data/backup.gemspec
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{backup-gundua}
|
8
|
+
s.version = "2.3.1.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Michael van Rooijen"]
|
12
|
+
s.date = %q{2010-05-04}
|
13
|
+
s.default_executable = %q{backup}
|
14
|
+
s.description = %q{
|
15
|
+
Backup is a Ruby Gem written for Unix and Rails environments. It can be used both with and without the
|
16
|
+
Ruby on Rails framework! This gem offers a quick and simple solution to backing up databases such as
|
17
|
+
MySQL/PostgreSQL and Files/Folders. All backups can be transferred to Amazon S3 or any remote server you
|
18
|
+
have access to, using either SCP, SFTP or regular FTP. Backup handles Compression, Archiving, Encryption
|
19
|
+
and Backup Cleaning (Cycling).
|
20
|
+
}
|
21
|
+
s.email = %q{hendrik.louw@gundua.co.za}
|
22
|
+
s.executables = ["backup"]
|
23
|
+
s.extra_rdoc_files = [
|
24
|
+
"LICENSE",
|
25
|
+
"README.textile"
|
26
|
+
]
|
27
|
+
s.files = [
|
28
|
+
".document",
|
29
|
+
".gitignore",
|
30
|
+
"CHANGELOG",
|
31
|
+
"LICENSE",
|
32
|
+
"README.textile",
|
33
|
+
"Rakefile",
|
34
|
+
"VERSION",
|
35
|
+
"backup.gemspec",
|
36
|
+
"bin/backup",
|
37
|
+
"generators/backup/backup_generator.rb",
|
38
|
+
"generators/backup/templates/config/backup.rb",
|
39
|
+
"generators/backup/templates/migrations/create_backup_tables.rb",
|
40
|
+
"generators/backup/templates/tasks/backup.rake",
|
41
|
+
"generators/backup_update/backup_update_generator.rb",
|
42
|
+
"generators/backup_update/templates/migrations/update_backup_tables.rb",
|
43
|
+
"lib/backup.rb",
|
44
|
+
"lib/backup/adapters/archive.rb",
|
45
|
+
"lib/backup/adapters/base.rb",
|
46
|
+
"lib/backup/adapters/custom.rb",
|
47
|
+
"lib/backup/adapters/mysql.rb",
|
48
|
+
"lib/backup/adapters/postgresql.rb",
|
49
|
+
"lib/backup/adapters/sqlite.rb",
|
50
|
+
"lib/backup/command_helper.rb",
|
51
|
+
"lib/backup/configuration/adapter.rb",
|
52
|
+
"lib/backup/configuration/adapter_options.rb",
|
53
|
+
"lib/backup/configuration/attributes.rb",
|
54
|
+
"lib/backup/configuration/base.rb",
|
55
|
+
"lib/backup/configuration/helpers.rb",
|
56
|
+
"lib/backup/configuration/mail.rb",
|
57
|
+
"lib/backup/configuration/smtp.rb",
|
58
|
+
"lib/backup/configuration/storage.rb",
|
59
|
+
"lib/backup/connection/s3.rb",
|
60
|
+
"lib/backup/environment/base.rb",
|
61
|
+
"lib/backup/environment/rails.rb",
|
62
|
+
"lib/backup/environment/unix.rb",
|
63
|
+
"lib/backup/mail/base.rb",
|
64
|
+
"lib/backup/mail/mail.txt",
|
65
|
+
"lib/backup/record/base.rb",
|
66
|
+
"lib/backup/record/ftp.rb",
|
67
|
+
"lib/backup/record/local.rb",
|
68
|
+
"lib/backup/record/s3.rb",
|
69
|
+
"lib/backup/record/scp.rb",
|
70
|
+
"lib/backup/record/sftp.rb",
|
71
|
+
"lib/backup/storage/ftp.rb",
|
72
|
+
"lib/backup/storage/local.rb",
|
73
|
+
"lib/backup/storage/s3.rb",
|
74
|
+
"lib/backup/storage/scp.rb",
|
75
|
+
"lib/backup/storage/sftp.rb",
|
76
|
+
"setup/backup.rb",
|
77
|
+
"setup/backup.sqlite3",
|
78
|
+
"spec/configuration/attributes_spec.rb"
|
79
|
+
]
|
80
|
+
s.homepage = %q{http://final-creation.com/open-source}
|
81
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
82
|
+
s.require_paths = ["lib"]
|
83
|
+
s.rubygems_version = %q{1.3.5}
|
84
|
+
s.summary = %q{Backup is a Ruby Gem that simplifies making backups for databases, files and folders.}
|
85
|
+
s.test_files = [
|
86
|
+
"spec/configuration/attributes_spec.rb"
|
87
|
+
]
|
88
|
+
|
89
|
+
if s.respond_to? :specification_version then
|
90
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
91
|
+
s.specification_version = 3
|
92
|
+
|
93
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
94
|
+
s.add_runtime_dependency(%q<aws-s3>, [">= 0.6.2"])
|
95
|
+
s.add_runtime_dependency(%q<net-ssh>, [">= 2.0.15"])
|
96
|
+
s.add_runtime_dependency(%q<net-scp>, [">= 1.0.2"])
|
97
|
+
s.add_runtime_dependency(%q<net-sftp>, [">= 2.0.4"])
|
98
|
+
s.add_runtime_dependency(%q<activerecord>, [">= 2.3.5"])
|
99
|
+
s.add_runtime_dependency(%q<sqlite3-ruby>, [">= 1.2.5"])
|
100
|
+
s.add_runtime_dependency(%q<hirb>, [">= 0.2.9"])
|
101
|
+
s.add_runtime_dependency(%q<pony>, [">= 0.5"])
|
102
|
+
else
|
103
|
+
s.add_dependency(%q<aws-s3>, [">= 0.6.2"])
|
104
|
+
s.add_dependency(%q<net-ssh>, [">= 2.0.15"])
|
105
|
+
s.add_dependency(%q<net-scp>, [">= 1.0.2"])
|
106
|
+
s.add_dependency(%q<net-sftp>, [">= 2.0.4"])
|
107
|
+
s.add_dependency(%q<activerecord>, [">= 2.3.5"])
|
108
|
+
s.add_dependency(%q<sqlite3-ruby>, [">= 1.2.5"])
|
109
|
+
s.add_dependency(%q<hirb>, [">= 0.2.9"])
|
110
|
+
s.add_dependency(%q<pony>, [">= 0.5"])
|
111
|
+
end
|
112
|
+
else
|
113
|
+
s.add_dependency(%q<aws-s3>, [">= 0.6.2"])
|
114
|
+
s.add_dependency(%q<net-ssh>, [">= 2.0.15"])
|
115
|
+
s.add_dependency(%q<net-scp>, [">= 1.0.2"])
|
116
|
+
s.add_dependency(%q<net-sftp>, [">= 2.0.4"])
|
117
|
+
s.add_dependency(%q<activerecord>, [">= 2.3.5"])
|
118
|
+
s.add_dependency(%q<sqlite3-ruby>, [">= 1.2.5"])
|
119
|
+
s.add_dependency(%q<hirb>, [">= 0.2.9"])
|
120
|
+
s.add_dependency(%q<pony>, [">= 0.5"])
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
data/bin/backup
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'backup'
|
4
|
+
|
5
|
+
include Backup::Environment::Unix::Commands
|
6
|
+
include Backup::Environment::Unix::Helpers
|
7
|
+
|
8
|
+
options = {}
|
9
|
+
|
10
|
+
optparse = OptionParser.new do |opts|
|
11
|
+
|
12
|
+
opts.banner = "\nUsage: backup [options]\n "
|
13
|
+
|
14
|
+
opts.on('-r', '--run [trigger]', "Runs backup process by trigger") do |trigger|
|
15
|
+
confirm_configuration_file_existence
|
16
|
+
puts "Running: #{trigger}."
|
17
|
+
Backup::Setup.new(trigger, @backup_procedures).initialize_adapter
|
18
|
+
end
|
19
|
+
|
20
|
+
opts.on('-f', '--find [trigger]', "Finds backup records by trigger") do |trigger|
|
21
|
+
confirm_configuration_file_existence
|
22
|
+
puts "Finding backup records with trigger: #{trigger}."
|
23
|
+
backup = Backup::Setup.new(trigger, @backup_procedures)
|
24
|
+
records = Array.new
|
25
|
+
case backup.procedure.storage_name.to_sym
|
26
|
+
when :s3 then records = Backup::Record::S3.all :conditions => {:trigger => trigger}
|
27
|
+
when :scp then records = Backup::Record::SCP.all :conditions => {:trigger => trigger}
|
28
|
+
when :ftp then records = Backup::Record::FTP.all :conditions => {:trigger => trigger}
|
29
|
+
when :sftp then records = Backup::Record::SFTP.all :conditions => {:trigger => trigger}
|
30
|
+
when :local then records = Backup::Record::Local.all :conditions => {:trigger => trigger}
|
31
|
+
end
|
32
|
+
|
33
|
+
if options[:table]
|
34
|
+
puts Hirb::Helpers::AutoTable.render(records)
|
35
|
+
else
|
36
|
+
records.each do |record|
|
37
|
+
puts record.to_yaml
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
opts.on('-t', '--truncate [trigger]', "Truncates backup records for specified trigger") do |trigger|
|
43
|
+
puts "Truncating backup records with trigger: #{trigger}."
|
44
|
+
Backup::Record::Base.destroy_all :trigger => trigger
|
45
|
+
end
|
46
|
+
|
47
|
+
opts.on('-d', '--destroy [trigger]', "Destroys backup records and files for specified trigger") do |trigger|
|
48
|
+
confirm_configuration_file_existence
|
49
|
+
puts "Destroying backup records with trigger: #{trigger}."
|
50
|
+
backup = Backup::Setup.new(trigger, @backup_procedures)
|
51
|
+
case backup.procedure.storage_name.to_sym
|
52
|
+
when :s3 then Backup::Record::S3.destroy_all_backups backup.procedure, trigger
|
53
|
+
when :scp then Backup::Record::SCP.destroy_all_backups backup.procedure, trigger
|
54
|
+
when :ftp then Backup::Record::FTP.destroy_all_backups backup.procedure, trigger
|
55
|
+
when :sftp then Backup::Record::SFTP.destroy_all_backups backup.procedure, trigger
|
56
|
+
when :local then Backup::Record::Local.destroy_all_backups backup.procedure, trigger
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
opts.on('--truncate-all', "Truncates all backup records") do
|
61
|
+
puts "Truncating all backup records."
|
62
|
+
Backup::Record::Base.destroy_all
|
63
|
+
end
|
64
|
+
|
65
|
+
opts.on('--destroy-all', "Destroys all backup records and files") do
|
66
|
+
confirm_configuration_file_existence
|
67
|
+
puts "Destroying all backup records."
|
68
|
+
backup = Backup::Setup.new(false, @backup_procedures)
|
69
|
+
backup.procedures.each do |backup_procedure|
|
70
|
+
case backup_procedure.storage_name.to_sym
|
71
|
+
when :s3 then Backup::Record::S3.destroy_all_backups backup_procedure, backup_procedure.trigger
|
72
|
+
when :scp then Backup::Record::SCP.destroy_all_backups backup_procedure, backup_procedure.trigger
|
73
|
+
when :ftp then Backup::Record::FTP.destroy_all_backups backup_procedure, backup_procedure.trigger
|
74
|
+
when :sftp then Backup::Record::SFTP.destroy_all_backups backup_procedure, backup_procedure.trigger
|
75
|
+
when :local then Backup::Record::Local.destroy_all_backups backup.procedure, backup_procedure.trigger
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
opts.on('--decrypt [file]', "Decrypts a \"Backup\" encrypted file") do |file|
|
81
|
+
puts "Attempting to decrypt: #{file}."
|
82
|
+
%x{ openssl enc -des-cbc -d -in #{file} -out #{file.gsub('.enc', '')} }
|
83
|
+
end
|
84
|
+
|
85
|
+
options[:table] = false
|
86
|
+
opts.on('--table', "Shows records in table format") do |format|
|
87
|
+
options[:table] = true
|
88
|
+
end
|
89
|
+
|
90
|
+
opts.on('--setup', "Sets up Backup") do
|
91
|
+
setup
|
92
|
+
end
|
93
|
+
|
94
|
+
opts.on('--reset', "Reinstalls Backup (This will remove ALL current settings!)") do
|
95
|
+
reset
|
96
|
+
end
|
97
|
+
|
98
|
+
opts.on('--remove', "Removes Backup (This will remove ALL current settings!)") do
|
99
|
+
remove
|
100
|
+
end
|
101
|
+
|
102
|
+
opts.on('-v', '--version', 'Displays installed Backup version') do
|
103
|
+
File.open(File.join(File.dirname(__FILE__), '..', 'VERSION')) do |file|
|
104
|
+
puts "Backup version #{file.read}"
|
105
|
+
end
|
106
|
+
exit
|
107
|
+
end
|
108
|
+
|
109
|
+
opts.on('-h', '--help', 'Display help screen') do
|
110
|
+
puts opts
|
111
|
+
puts "\n "
|
112
|
+
exit
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
|
117
|
+
begin
|
118
|
+
optparse.parse!
|
119
|
+
rescue OptionParser::InvalidOption
|
120
|
+
puts "\nInvalid Option. See the list of available options below.\n"
|
121
|
+
puts optparse
|
122
|
+
puts "\n "
|
123
|
+
exit
|
124
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
class BackupGenerator < Rails::Generator::Base
|
2
|
+
|
3
|
+
# This method gets initialized when the generator gets run.
|
4
|
+
# It will receive an array of arguments inside @args
|
5
|
+
def initialize(runtime_args, runtime_options = {})
|
6
|
+
super
|
7
|
+
end
|
8
|
+
|
9
|
+
# Processes the file generation/templating
|
10
|
+
# This will automatically be run after the initialize method
|
11
|
+
def manifest
|
12
|
+
record do |m|
|
13
|
+
|
14
|
+
# Generates the Rake Tasks and Backup Database
|
15
|
+
m.directory "lib/tasks"
|
16
|
+
m.directory "lib/tasks/backup"
|
17
|
+
m.file "tasks/backup.rake", "lib/tasks/backup/backup.rake"
|
18
|
+
|
19
|
+
# Generates the configuration file
|
20
|
+
m.directory "config"
|
21
|
+
m.file "config/backup.rb", "config/backup.rb"
|
22
|
+
|
23
|
+
# Generates the database migration file
|
24
|
+
m.migration_template "migrations/create_backup_tables.rb",
|
25
|
+
"db/migrate",
|
26
|
+
:migration_file_name => "create_backup_tables"
|
27
|
+
|
28
|
+
# Outputs the generators message to the terminal
|
29
|
+
puts message
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def message
|
34
|
+
<<-MESSAGE
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
==============================================================
|
39
|
+
Backup's files have been generated!
|
40
|
+
==============================================================
|
41
|
+
|
42
|
+
1: Add the "Backup" gem to the config/environment.rb file!
|
43
|
+
|
44
|
+
config.gem "backup"
|
45
|
+
|
46
|
+
|
47
|
+
2: Migrate the database!
|
48
|
+
|
49
|
+
rake db:migrate
|
50
|
+
|
51
|
+
|
52
|
+
3: Set up some "Backup Settings" inside the backup configuration file!
|
53
|
+
|
54
|
+
config/backup.rb
|
55
|
+
|
56
|
+
|
57
|
+
4: Run the backups! Enjoy.
|
58
|
+
|
59
|
+
rake backup:run trigger="your-specified-trigger"
|
60
|
+
|
61
|
+
|
62
|
+
For More Information:
|
63
|
+
http://github.com/meskyanichi/backup
|
64
|
+
|
65
|
+
==============================================================
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
MESSAGE
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|