backup_rails 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -16,9 +16,15 @@ Or install it yourself as:
16
16
 
17
17
  $ gem install backup_rails
18
18
 
19
+ ## TODO
20
+
21
+ * Add Rails generator for simple backup scripts.
22
+
19
23
  ## Usage
20
24
 
21
- TODO: Write usage instructions here
25
+ For now just add the gem to your Gemfile.
26
+ Move the files in /examples dir into your project.
27
+ Run whenever to setup your cron job. Make sure you've set the RAILS_ENV correctly.
22
28
 
23
29
  ## Contributing
24
30
 
data/backup_rails.gemspec CHANGED
@@ -16,9 +16,9 @@ Gem::Specification.new do |gem|
16
16
  gem.version = BackupRails::VERSION
17
17
 
18
18
  # For backup
19
- gem.add_dependency 'backup', '~> 3.0.24'
20
- gem.add_dependency 'net-ssh', '~> 2.3.0'
21
- gem.add_dependency 'net-sftp', '~> 2.0.5'
22
- gem.add_dependency 'mail', '~> 2.4.0'
19
+ gem.add_dependency 'backup', '>= 3.0.24'
20
+ gem.add_dependency 'net-ssh'
21
+ gem.add_dependency 'net-sftp'
22
+ gem.add_dependency 'mail'
23
23
  gem.add_dependency 'whenever' # For cronjob config, see config/schedule.rb
24
24
  end
@@ -0,0 +1,80 @@
1
+ # encoding: utf-8
2
+
3
+ # Put this file in rails_project/config/backup.rb
4
+
5
+ # This is the backup gem config file. Run it from the Rails root using:
6
+ # backup perform --trigger your_project --config_file config/backup.rb --data-path db --log-path log --tmp-path tmp
7
+
8
+ # Read production db config from Rails app.
9
+ require 'yaml'
10
+ RAILS_ENV = ENV['RAILS_ENV'] || 'development'
11
+ APP_ROOT = File.expand_path('..', File.dirname(__FILE__))
12
+ APP_DB_CONFIG = YAML.load_file(File.join(APP_ROOT, '/config/database.yml'))[RAILS_ENV]
13
+
14
+ ##
15
+ # Backup Generated: my_backup
16
+ # Once configured, you can run the backup with the following command:
17
+ #
18
+ # $ backup perform -t my_backup [-c <path_to_configuration_file>]
19
+ #
20
+ Backup::Model.new(:your_project, 'Backup of YourProject DB and Assets') do
21
+ ##
22
+ # Split [Splitter]
23
+ #
24
+ # Split the backup file in to chunks of 250 megabytes
25
+ # if the backup file size exceeds 250 megabytes
26
+ #
27
+ split_into_chunks_of 250
28
+
29
+ ##
30
+ # MySQL [Database]
31
+ #
32
+ database MySQL do |db|
33
+ # To dump all databases, set `db.name = :all` (or leave blank)
34
+ db.name = APP_DB_CONFIG['database']
35
+ db.username = APP_DB_CONFIG['username']
36
+ db.password = APP_DB_CONFIG['password']
37
+ db.host = "localhost"
38
+ db.port = 3306
39
+ # db.socket = "/tmp/mysql.sock"
40
+ # Note: when using `skip_tables` with the `db.name = :all` option,
41
+ # table names should be prefixed with a database name.
42
+ # e.g. ["db_name.table_to_skip", ...]
43
+ # db.skip_tables = ["skip", "these", "tables"]
44
+ # db.only_tables = ["only", "these" "tables"]
45
+ db.additional_options = ["--quick", "--single-transaction"]
46
+ # Optional: Use to set the location of this utility
47
+ # if it cannot be found by name in your $PATH
48
+ # db.mysqldump_utility = "/opt/local/bin/mysqldump"
49
+ # db.mysqldump_utility = "/usr/local/mysql-5.5.15-osx10.6-x86_64/bin/mysqldump"
50
+ end
51
+
52
+ store_with SFTP, "YourServer" do |server|
53
+ server.username = 'user'
54
+ # server.password = 'secret'
55
+ server.ip = 'your_server.nl'
56
+ server.port = 22
57
+ server.path = '~/backups'
58
+ server.keep = 5
59
+ end
60
+
61
+ ##
62
+ # Gzip [Compressor]
63
+ #
64
+ # compress_with Gzip
65
+
66
+ notify_by Mail do |mail|
67
+ mail.on_success = false
68
+ mail.on_warning = true
69
+ mail.on_failure = true
70
+
71
+ mail.delivery_method = :sendmail
72
+ mail.from = 'no-reply@your_project.com'
73
+ mail.to = 'your@email.com'
74
+
75
+ # optional settings:
76
+ # mail.sendmail # the full path to the `sendmail` program
77
+ # mail.sendmail_args # string of arguments to to pass to `sendmail`
78
+ end
79
+
80
+ end
@@ -0,0 +1,8 @@
1
+ # Put this file in rails_project/config/schedule.rb
2
+
3
+ # Backup using the RAILS_ROOT/config/backup.rb backup gem script.
4
+ # Schedule it using:
5
+ # whenever
6
+ every 1.day, :at => '2:30 am' do
7
+ command "bundle exec backup perform --trigger your_project --config_file config/backup.rb --data-path db --log-path log --tmp-path tmp"
8
+ end
@@ -1,3 +1,3 @@
1
1
  module BackupRails
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/backup_rails.rb CHANGED
@@ -2,4 +2,5 @@ require "backup_rails/version"
2
2
 
3
3
  module BackupRails
4
4
  # Your code goes here...
5
+ # FIXME: Not needed?
5
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: backup_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -16,7 +16,7 @@ dependencies:
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ~>
19
+ - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
21
  version: 3.0.24
22
22
  type: :runtime
@@ -24,7 +24,7 @@ dependencies:
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - ~>
27
+ - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: 3.0.24
30
30
  - !ruby/object:Gem::Dependency
@@ -32,49 +32,49 @@ dependencies:
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
35
- - - ~>
35
+ - - ! '>='
36
36
  - !ruby/object:Gem::Version
37
- version: 2.3.0
37
+ version: '0'
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
- - - ~>
43
+ - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
- version: 2.3.0
45
+ version: '0'
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: net-sftp
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  none: false
50
50
  requirements:
51
- - - ~>
51
+ - - ! '>='
52
52
  - !ruby/object:Gem::Version
53
- version: 2.0.5
53
+ version: '0'
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  none: false
58
58
  requirements:
59
- - - ~>
59
+ - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
- version: 2.0.5
61
+ version: '0'
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: mail
64
64
  requirement: !ruby/object:Gem::Requirement
65
65
  none: false
66
66
  requirements:
67
- - - ~>
67
+ - - ! '>='
68
68
  - !ruby/object:Gem::Version
69
- version: 2.4.0
69
+ version: '0'
70
70
  type: :runtime
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
- - - ~>
75
+ - - ! '>='
76
76
  - !ruby/object:Gem::Version
77
- version: 2.4.0
77
+ version: '0'
78
78
  - !ruby/object:Gem::Dependency
79
79
  name: whenever
80
80
  requirement: !ruby/object:Gem::Requirement
@@ -104,6 +104,8 @@ files:
104
104
  - README.md
105
105
  - Rakefile
106
106
  - backup_rails.gemspec
107
+ - examples/backup.rb
108
+ - examples/schedule.rb
107
109
  - lib/backup_rails.rb
108
110
  - lib/backup_rails/version.rb
109
111
  homepage: ''