guitsaru-rails_backup 1.0.0
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.
- data/History.txt +3 -0
- data/Manifest.txt +20 -0
- data/README.textile +65 -0
- data/Rakefile +27 -0
- data/bin/rails_backup +17 -0
- data/lib/rails_backup.rb +73 -0
- data/test/config.yml.erb +9 -0
- data/test/sample_rails_project/config/boot.rb +109 -0
- data/test/sample_rails_project/config/database.yml +12 -0
- data/test/sample_rails_project/config/environment.rb +11 -0
- data/test/sample_rails_project/config/environments/mysql.rb +17 -0
- data/test/sample_rails_project/config/environments/sqlite3.rb +17 -0
- data/test/sample_rails_project/config/initializers/inflections.rb +10 -0
- data/test/sample_rails_project/config/initializers/mime_types.rb +5 -0
- data/test/sample_rails_project/config/initializers/new_rails_defaults.rb +17 -0
- data/test/sample_rails_project/config/locales/en.yml +5 -0
- data/test/sample_rails_project/config/routes.rb +43 -0
- data/test/sample_rails_project/db/sqlite.sqlite3 +0 -0
- data/test/sample_rails_project/public/uploads/uploaded_image.png +0 -0
- data/test/test_rails_backup.rb +71 -0
- metadata +95 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
History.txt
|
2
|
+
Manifest.txt
|
3
|
+
README.textile
|
4
|
+
Rakefile
|
5
|
+
bin/rails_backup
|
6
|
+
lib/rails_backup.rb
|
7
|
+
test/test_rails_backup.rb
|
8
|
+
test/config.yml.erb
|
9
|
+
test/sample_rails_project/config/boot.rb
|
10
|
+
test/sample_rails_project/config/database.yml
|
11
|
+
test/sample_rails_project/config/environment.rb
|
12
|
+
test/sample_rails_project/config/environments/mysql.rb
|
13
|
+
test/sample_rails_project/config/environments/sqlite3.rb
|
14
|
+
test/sample_rails_project/config/initializers/inflections.rb
|
15
|
+
test/sample_rails_project/config/initializers/mime_types.rb
|
16
|
+
test/sample_rails_project/config/initializers/new_rails_defaults.rb
|
17
|
+
test/sample_rails_project/config/locales/en.yml
|
18
|
+
test/sample_rails_project/config/routes.rb
|
19
|
+
test/sample_rails_project/db/sqlite.sqlite3
|
20
|
+
test/sample_rails_project/public/uploads/uploaded_image.png
|
data/README.textile
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
h1. rails_backup
|
2
|
+
|
3
|
+
by Matt Pruitt
|
4
|
+
|
5
|
+
http://guitsaru.com
|
6
|
+
|
7
|
+
h2. DESCRIPTION:
|
8
|
+
|
9
|
+
Automatically backup your rails database and other files to a git repository.
|
10
|
+
|
11
|
+
h2. FEATURES/PROBLEMS:
|
12
|
+
|
13
|
+
Backs up your rails project's database files and any other files specified in the configuration.
|
14
|
+
|
15
|
+
h2. SYNOPSIS:
|
16
|
+
|
17
|
+
@rails_backup /var/www/apps/project/config/rails_backup.yml@
|
18
|
+
|
19
|
+
h2. INSTALL:
|
20
|
+
|
21
|
+
@sudo gem install rails_backup@
|
22
|
+
|
23
|
+
h2. Sample Configuration
|
24
|
+
|
25
|
+
* The user values are used for the repository's git configuration.
|
26
|
+
* root is the root to your rails project.
|
27
|
+
* repository is the remote repository to push the backup to.
|
28
|
+
* files is a list of other files to backup relative to the root directory.
|
29
|
+
|
30
|
+
<pre>
|
31
|
+
user:
|
32
|
+
name: User Name
|
33
|
+
email: user@email.com
|
34
|
+
root: /var/www/apps/sample_rails_project
|
35
|
+
backup_directory: /home/deploy/backup
|
36
|
+
repository: git@github.com:user/repo_backup.git
|
37
|
+
environment: production
|
38
|
+
files:
|
39
|
+
- public/uploads/
|
40
|
+
</pre>
|
41
|
+
|
42
|
+
h2. LICENSE:
|
43
|
+
|
44
|
+
(The MIT License)
|
45
|
+
|
46
|
+
Copyright (c) 2008 Matt Pruitt
|
47
|
+
|
48
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
49
|
+
a copy of this software and associated documentation files (the
|
50
|
+
'Software'), to deal in the Software without restriction, including
|
51
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
52
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
53
|
+
permit persons to whom the Software is furnished to do so, subject to
|
54
|
+
the following conditions:
|
55
|
+
|
56
|
+
The above copyright notice and this permission notice shall be
|
57
|
+
included in all copies or substantial portions of the Software.
|
58
|
+
|
59
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
60
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
61
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
62
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
63
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
64
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
65
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# Look in the tasks/setup.rb file for the various options that can be
|
2
|
+
# configured in this Rakefile. The .rake files in the tasks directory
|
3
|
+
# are where the options are used.
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'bones'
|
7
|
+
Bones.setup
|
8
|
+
rescue LoadError
|
9
|
+
load 'tasks/setup.rb'
|
10
|
+
end
|
11
|
+
|
12
|
+
ensure_in_path 'lib'
|
13
|
+
require 'rails_backup'
|
14
|
+
|
15
|
+
task :default => 'test:run'
|
16
|
+
|
17
|
+
PROJ.name = 'rails_backup'
|
18
|
+
PROJ.authors = 'Matt Pruitt'
|
19
|
+
PROJ.email = 'guitsaru@gmail.com'
|
20
|
+
PROJ.url = 'http://github.com/guitsaru/rails_backup'
|
21
|
+
PROJ.version = '1.0.0'
|
22
|
+
PROJ.summary = "Automatically backup your rails database and other files to a git repository."
|
23
|
+
PROJ.rubyforge.name = 'rails-backup'
|
24
|
+
|
25
|
+
PROJ.spec.opts << '--color'
|
26
|
+
|
27
|
+
# EOF
|
data/bin/rails_backup
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rails_backup'
|
4
|
+
|
5
|
+
unless ARGV.first
|
6
|
+
puts "Specify a rails_backup configuration file to use:"
|
7
|
+
puts "rails_backup /path/to/config/file"
|
8
|
+
exit
|
9
|
+
end
|
10
|
+
|
11
|
+
begin
|
12
|
+
rails_backup = RailsBackup.new(ARGV.first)
|
13
|
+
rails_backup.backup
|
14
|
+
rescue Exception => e
|
15
|
+
puts "Backup Failed:"
|
16
|
+
puts e
|
17
|
+
end
|
data/lib/rails_backup.rb
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'ftools'
|
3
|
+
|
4
|
+
class RailsBackup
|
5
|
+
def initialize(config_file)
|
6
|
+
@config = YAML.load_file(config_file)
|
7
|
+
@db_config = YAML.load_file(@config['root'] + '/config/database.yml')[@config['environment']]
|
8
|
+
end
|
9
|
+
|
10
|
+
def backup
|
11
|
+
copy_files
|
12
|
+
git_push
|
13
|
+
end
|
14
|
+
|
15
|
+
def copy_files
|
16
|
+
# Create Backup Directory if it doesn't exist
|
17
|
+
File.makedirs(@config['backup_directory'])
|
18
|
+
|
19
|
+
backup_files
|
20
|
+
backup_database
|
21
|
+
end
|
22
|
+
|
23
|
+
def git_push
|
24
|
+
git_initialize
|
25
|
+
git_add
|
26
|
+
git_push_repository
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
def backup_files
|
31
|
+
@config['files'].each do |file|
|
32
|
+
source = File.join(@config['root'], file)
|
33
|
+
destination = File.join(@config['backup_directory'], file)
|
34
|
+
File.makedirs(File.dirname(destination))
|
35
|
+
File.copy(source, destination) unless File.directory?(source)
|
36
|
+
|
37
|
+
if File.directory?(source)
|
38
|
+
File.makedirs(destination)
|
39
|
+
|
40
|
+
FileUtils.cp_r(source, File.dirname(destination))
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def backup_database
|
46
|
+
if @db_config['adapter'] == 'sqlite3'
|
47
|
+
source = File.join(@config['root'], @db_config['database'])
|
48
|
+
destination = File.join(@config['backup_directory'], @db_config['database'])
|
49
|
+
File.makedirs(File.dirname(destination))
|
50
|
+
File.copy(source, destination)
|
51
|
+
elsif @db_config['adapter'] == 'mysql'
|
52
|
+
dump_string = "mysqldump -u#{@db_config['username']} "
|
53
|
+
dump_string += "-p#{@db_config['password']} " if @db_config['password']
|
54
|
+
dump_string += "#{@db_config['database']}"
|
55
|
+
|
56
|
+
destination = File.join(@config['backup_directory'], 'db', "#{@db_config['database']}.sql")
|
57
|
+
File.makedirs(File.dirname(destination))
|
58
|
+
File.open(destination, 'w') { |f| f.write `#{dump_string}` }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def git_initialize
|
63
|
+
system("cd #{@config['backup_directory']} && git init && git config user.name'#{@config['user']['name']}' && git config user.email #{@config['user']['email']}") unless File.exist?(File.join(@config['backup_directory'], '.git'))
|
64
|
+
end
|
65
|
+
|
66
|
+
def git_add
|
67
|
+
system("cd #{@config['backup_directory']} && git add . && git commit -a -m 'Backing up #{DateTime.now}'")
|
68
|
+
end
|
69
|
+
|
70
|
+
def git_push_repository
|
71
|
+
system("cd #{@config['backup_directory']} && git push #{@config['repository']} master")
|
72
|
+
end
|
73
|
+
end
|
data/test/config.yml.erb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
user:
|
2
|
+
name: Matt Pruitt
|
3
|
+
email: guitsaru@gmail.com
|
4
|
+
root: /users/Matt/Documents/Code/Ruby/rails_backup/test/sample_rails_project
|
5
|
+
backup_directory: /users/Matt/Documents/Code/Ruby/rails_backup/test/backup
|
6
|
+
repository: git@github.com:guitsaru/rails_backup_test.git
|
7
|
+
environment: <%= environment %>
|
8
|
+
files:
|
9
|
+
- public/uploads/
|
@@ -0,0 +1,109 @@
|
|
1
|
+
# Don't change this file!
|
2
|
+
# Configure your app in config/environment.rb and config/environments/*.rb
|
3
|
+
|
4
|
+
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
|
5
|
+
|
6
|
+
module Rails
|
7
|
+
class << self
|
8
|
+
def boot!
|
9
|
+
unless booted?
|
10
|
+
preinitialize
|
11
|
+
pick_boot.run
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def booted?
|
16
|
+
defined? Rails::Initializer
|
17
|
+
end
|
18
|
+
|
19
|
+
def pick_boot
|
20
|
+
(vendor_rails? ? VendorBoot : GemBoot).new
|
21
|
+
end
|
22
|
+
|
23
|
+
def vendor_rails?
|
24
|
+
File.exist?("#{RAILS_ROOT}/vendor/rails")
|
25
|
+
end
|
26
|
+
|
27
|
+
def preinitialize
|
28
|
+
load(preinitializer_path) if File.exist?(preinitializer_path)
|
29
|
+
end
|
30
|
+
|
31
|
+
def preinitializer_path
|
32
|
+
"#{RAILS_ROOT}/config/preinitializer.rb"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
class Boot
|
37
|
+
def run
|
38
|
+
load_initializer
|
39
|
+
Rails::Initializer.run(:set_load_path)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
class VendorBoot < Boot
|
44
|
+
def load_initializer
|
45
|
+
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
|
46
|
+
Rails::Initializer.run(:install_gem_spec_stubs)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
class GemBoot < Boot
|
51
|
+
def load_initializer
|
52
|
+
self.class.load_rubygems
|
53
|
+
load_rails_gem
|
54
|
+
require 'initializer'
|
55
|
+
end
|
56
|
+
|
57
|
+
def load_rails_gem
|
58
|
+
if version = self.class.gem_version
|
59
|
+
gem 'rails', version
|
60
|
+
else
|
61
|
+
gem 'rails'
|
62
|
+
end
|
63
|
+
rescue Gem::LoadError => load_error
|
64
|
+
$stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
|
65
|
+
exit 1
|
66
|
+
end
|
67
|
+
|
68
|
+
class << self
|
69
|
+
def rubygems_version
|
70
|
+
Gem::RubyGemsVersion rescue nil
|
71
|
+
end
|
72
|
+
|
73
|
+
def gem_version
|
74
|
+
if defined? RAILS_GEM_VERSION
|
75
|
+
RAILS_GEM_VERSION
|
76
|
+
elsif ENV.include?('RAILS_GEM_VERSION')
|
77
|
+
ENV['RAILS_GEM_VERSION']
|
78
|
+
else
|
79
|
+
parse_gem_version(read_environment_rb)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def load_rubygems
|
84
|
+
require 'rubygems'
|
85
|
+
min_version = '1.3.1'
|
86
|
+
unless rubygems_version >= min_version
|
87
|
+
$stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
|
88
|
+
exit 1
|
89
|
+
end
|
90
|
+
|
91
|
+
rescue LoadError
|
92
|
+
$stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
|
93
|
+
exit 1
|
94
|
+
end
|
95
|
+
|
96
|
+
def parse_gem_version(text)
|
97
|
+
$1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
|
98
|
+
end
|
99
|
+
|
100
|
+
private
|
101
|
+
def read_environment_rb
|
102
|
+
File.read("#{RAILS_ROOT}/config/environment.rb")
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
# All that for this:
|
109
|
+
Rails.boot!
|
@@ -0,0 +1,11 @@
|
|
1
|
+
RAILS_GEM_VERSION = '2.2.2' unless defined? RAILS_GEM_VERSION
|
2
|
+
|
3
|
+
require File.join(File.dirname(__FILE__), 'boot')
|
4
|
+
|
5
|
+
Rails::Initializer.run do |config|
|
6
|
+
config.time_zone = 'UTC'
|
7
|
+
config.action_controller.session = {
|
8
|
+
:session_key => '_sample_rails_project_session',
|
9
|
+
:secret => '0d9bae460dc3317e91927c943076ac6b83eedcd7e968a04bd64f1a5ffe6ea66e848deb1170d61c3b17d5374f194dc8de8f5e9f2b47132ed483a349df2ac3afbb'
|
10
|
+
}
|
11
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Settings specified here will take precedence over those in config/environment.rb
|
2
|
+
|
3
|
+
# In the development environment your application's code is reloaded on
|
4
|
+
# every request. This slows down response time but is perfect for development
|
5
|
+
# since you don't have to restart the webserver when you make code changes.
|
6
|
+
config.cache_classes = false
|
7
|
+
|
8
|
+
# Log error messages when you accidentally call methods on nil.
|
9
|
+
config.whiny_nils = true
|
10
|
+
|
11
|
+
# Show full error reports and disable caching
|
12
|
+
config.action_controller.consider_all_requests_local = true
|
13
|
+
config.action_view.debug_rjs = true
|
14
|
+
config.action_controller.perform_caching = false
|
15
|
+
|
16
|
+
# Don't care if the mailer can't send
|
17
|
+
config.action_mailer.raise_delivery_errors = false
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Settings specified here will take precedence over those in config/environment.rb
|
2
|
+
|
3
|
+
# In the development environment your application's code is reloaded on
|
4
|
+
# every request. This slows down response time but is perfect for development
|
5
|
+
# since you don't have to restart the webserver when you make code changes.
|
6
|
+
config.cache_classes = false
|
7
|
+
|
8
|
+
# Log error messages when you accidentally call methods on nil.
|
9
|
+
config.whiny_nils = true
|
10
|
+
|
11
|
+
# Show full error reports and disable caching
|
12
|
+
config.action_controller.consider_all_requests_local = true
|
13
|
+
config.action_view.debug_rjs = true
|
14
|
+
config.action_controller.perform_caching = false
|
15
|
+
|
16
|
+
# Don't care if the mailer can't send
|
17
|
+
config.action_mailer.raise_delivery_errors = false
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Add new inflection rules using the following format
|
4
|
+
# (all these examples are active by default):
|
5
|
+
# ActiveSupport::Inflector.inflections do |inflect|
|
6
|
+
# inflect.plural /^(ox)$/i, '\1en'
|
7
|
+
# inflect.singular /^(ox)en/i, '\1'
|
8
|
+
# inflect.irregular 'person', 'people'
|
9
|
+
# inflect.uncountable %w( fish sheep )
|
10
|
+
# end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# These settings change the behavior of Rails 2 apps and will be defaults
|
2
|
+
# for Rails 3. You can remove this initializer when Rails 3 is released.
|
3
|
+
|
4
|
+
if defined?(ActiveRecord)
|
5
|
+
# Include Active Record class name as root for JSON serialized output.
|
6
|
+
ActiveRecord::Base.include_root_in_json = true
|
7
|
+
|
8
|
+
# Store the full class name (including module namespace) in STI type column.
|
9
|
+
ActiveRecord::Base.store_full_sti_class = true
|
10
|
+
end
|
11
|
+
|
12
|
+
# Use ISO 8601 format for JSON serialized times and dates.
|
13
|
+
ActiveSupport.use_standard_json_time_format = true
|
14
|
+
|
15
|
+
# Don't escape HTML entities in JSON, leave that for the #json_escape helper.
|
16
|
+
# if you're including raw json in an HTML page.
|
17
|
+
ActiveSupport.escape_html_entities_in_json = false
|
@@ -0,0 +1,43 @@
|
|
1
|
+
ActionController::Routing::Routes.draw do |map|
|
2
|
+
# The priority is based upon order of creation: first created -> highest priority.
|
3
|
+
|
4
|
+
# Sample of regular route:
|
5
|
+
# map.connect 'products/:id', :controller => 'catalog', :action => 'view'
|
6
|
+
# Keep in mind you can assign values other than :controller and :action
|
7
|
+
|
8
|
+
# Sample of named route:
|
9
|
+
# map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
|
10
|
+
# This route can be invoked with purchase_url(:id => product.id)
|
11
|
+
|
12
|
+
# Sample resource route (maps HTTP verbs to controller actions automatically):
|
13
|
+
# map.resources :products
|
14
|
+
|
15
|
+
# Sample resource route with options:
|
16
|
+
# map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
|
17
|
+
|
18
|
+
# Sample resource route with sub-resources:
|
19
|
+
# map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
|
20
|
+
|
21
|
+
# Sample resource route with more complex sub-resources
|
22
|
+
# map.resources :products do |products|
|
23
|
+
# products.resources :comments
|
24
|
+
# products.resources :sales, :collection => { :recent => :get }
|
25
|
+
# end
|
26
|
+
|
27
|
+
# Sample resource route within a namespace:
|
28
|
+
# map.namespace :admin do |admin|
|
29
|
+
# # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
|
30
|
+
# admin.resources :products
|
31
|
+
# end
|
32
|
+
|
33
|
+
# You can have the root of your site routed with map.root -- just remember to delete public/index.html.
|
34
|
+
# map.root :controller => "welcome"
|
35
|
+
|
36
|
+
# See how all your routes lay out with "rake routes"
|
37
|
+
|
38
|
+
# Install the default routes as the lowest priority.
|
39
|
+
# Note: These default routes make all actions in every controller accessible via GET requests. You should
|
40
|
+
# consider removing the them or commenting them out if you're using named routes and resources.
|
41
|
+
map.connect ':controller/:action/:id'
|
42
|
+
map.connect ':controller/:action/:id.:format'
|
43
|
+
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require "test/unit"
|
3
|
+
require 'context'
|
4
|
+
require 'erb'
|
5
|
+
|
6
|
+
require File.dirname(__FILE__) + '/../rails_backup'
|
7
|
+
|
8
|
+
def load_env(env)
|
9
|
+
template = ERB.new(File.open(File.dirname(__FILE__) + '/config.yml.erb', 'r') { |f| f.read })
|
10
|
+
|
11
|
+
environment = env
|
12
|
+
File.open(File.dirname(__FILE__) + '/config.yml', 'w') { |f| f.write(template.result(binding)) }
|
13
|
+
end
|
14
|
+
|
15
|
+
class TestRailsBackup < Test::Unit::TestCase
|
16
|
+
context "mysql" do
|
17
|
+
before do
|
18
|
+
load_env('mysql')
|
19
|
+
@rails_backup = RailsBackup.new(File.dirname(__FILE__) + '/config.yml')
|
20
|
+
end
|
21
|
+
|
22
|
+
context "copy files" do
|
23
|
+
before do
|
24
|
+
@rails_backup.copy_files
|
25
|
+
end
|
26
|
+
|
27
|
+
should "copy the database file" do
|
28
|
+
assert(File.exist?(File.dirname(__FILE__) + '/backup/db/backup.sql'), "No db file backed up.")
|
29
|
+
end
|
30
|
+
|
31
|
+
should "copy other files" do
|
32
|
+
assert(File.exist?(File.dirname(__FILE__) + '/backup/public/uploads/uploaded_image.png'), "No image backed up.")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "sqlite" do
|
38
|
+
before do
|
39
|
+
load_env('sqlite3')
|
40
|
+
@rails_backup = RailsBackup.new(File.dirname(__FILE__) + '/config.yml')
|
41
|
+
end
|
42
|
+
|
43
|
+
context "copy files" do
|
44
|
+
before do
|
45
|
+
@rails_backup.copy_files
|
46
|
+
end
|
47
|
+
|
48
|
+
should "copy the database file" do
|
49
|
+
assert(File.exist?(File.dirname(__FILE__) + '/backup/db/sqlite.sqlite3'), "No db file backed up.")
|
50
|
+
end
|
51
|
+
|
52
|
+
should "copy other files" do
|
53
|
+
assert(File.exist?(File.dirname(__FILE__) + '/backup/public/uploads/uploaded_image.png'), "No image backed up.")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context "git" do
|
59
|
+
before do
|
60
|
+
load_env('sqlite3')
|
61
|
+
@rails_backup = RailsBackup.new(File.dirname(__FILE__) + '/config.yml')
|
62
|
+
@rails_backup.copy_files
|
63
|
+
@rails_backup.git_push
|
64
|
+
end
|
65
|
+
|
66
|
+
should "initialize the repository" do
|
67
|
+
assert(File.exist?(File.dirname(__FILE__) + '/backup/.git'), "No git repository found")
|
68
|
+
assert(File.open(File.dirname(__FILE__) + '/backup/.git/config') { |f| f.read } =~ /Matt Pruitt/, "Git repository not configured")
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: guitsaru-rails_backup
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Matt Pruitt
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-12-01 00:00:00 -08:00
|
13
|
+
default_executable: rails_backup
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: bones
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 2.1.0
|
23
|
+
version:
|
24
|
+
description: ""
|
25
|
+
email: guitsaru@gmail.com
|
26
|
+
executables:
|
27
|
+
- rails_backup
|
28
|
+
extensions: []
|
29
|
+
|
30
|
+
extra_rdoc_files:
|
31
|
+
- History.txt
|
32
|
+
- bin/rails_backup
|
33
|
+
files:
|
34
|
+
- History.txt
|
35
|
+
- Manifest.txt
|
36
|
+
- README.textile
|
37
|
+
- Rakefile
|
38
|
+
- bin/rails_backup
|
39
|
+
- lib/rails_backup.rb
|
40
|
+
- tasks/ann.rake
|
41
|
+
- tasks/bones.rake
|
42
|
+
- tasks/gem.rake
|
43
|
+
- tasks/git.rake
|
44
|
+
- tasks/manifest.rake
|
45
|
+
- tasks/notes.rake
|
46
|
+
- tasks/post_load.rake
|
47
|
+
- tasks/rdoc.rake
|
48
|
+
- tasks/rubyforge.rake
|
49
|
+
- tasks/setup.rb
|
50
|
+
- tasks/spec.rake
|
51
|
+
- tasks/svn.rake
|
52
|
+
- tasks/test.rake
|
53
|
+
- test/config.yml.erb
|
54
|
+
- test/sample_rails_project/config/boot.rb
|
55
|
+
- test/sample_rails_project/config/database.yml
|
56
|
+
- test/sample_rails_project/config/environment.rb
|
57
|
+
- test/sample_rails_project/config/environments/mysql.rb
|
58
|
+
- test/sample_rails_project/config/environments/sqlite3.rb
|
59
|
+
- test/sample_rails_project/config/initializers/inflections.rb
|
60
|
+
- test/sample_rails_project/config/initializers/mime_types.rb
|
61
|
+
- test/sample_rails_project/config/initializers/new_rails_defaults.rb
|
62
|
+
- test/sample_rails_project/config/locales/en.yml
|
63
|
+
- test/sample_rails_project/config/routes.rb
|
64
|
+
- test/sample_rails_project/db/sqlite.sqlite3
|
65
|
+
- test/sample_rails_project/public/uploads/uploaded_image.png
|
66
|
+
- test/test_rails_backup.rb
|
67
|
+
has_rdoc: true
|
68
|
+
homepage: http://github.com/guitsaru/rails_backup
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options:
|
71
|
+
- --main
|
72
|
+
- README.textile
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: "0"
|
80
|
+
version:
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: "0"
|
86
|
+
version:
|
87
|
+
requirements: []
|
88
|
+
|
89
|
+
rubyforge_project: rails-backup
|
90
|
+
rubygems_version: 1.2.0
|
91
|
+
signing_key:
|
92
|
+
specification_version: 2
|
93
|
+
summary: Automatically backup your rails database and other files to a git repository.
|
94
|
+
test_files:
|
95
|
+
- test/test_rails_backup.rb
|