Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: joost/backup_rails
base: 57e2dd8877
...
head fork: joost/backup_rails
compare: 876d6234c9
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 7 files changed
  • 0 commit comments
  • 1 contributor
Commits on Jul 13, 2012
@joost Added example files. 3ae6631
Commits on Jul 19, 2012
@joost Some new info. 876d623
View
12 README.md
@@ -16,9 +16,19 @@ Or install it yourself as:
$ gem install backup_rails
+## TODO
+
+* Add Rails generator for simple backup scripts.
+
## Usage
-TODO: Write usage instructions here
+For now just add the gem to your Gemfile.
+Move the files in /examples dir into your project.
+Run whenever to setup your cron job. Make sure you've set the RAILS_ENV correctly.
+
+When cron jobs are not run make sure you:
+
+ sudo touch /etc/cron.deny
## Contributing
View
3  backup_rails.gemspec
@@ -16,7 +16,8 @@ Gem::Specification.new do |gem|
gem.version = BackupRails::VERSION
# For backup
- gem.add_dependency 'backup', '~> 3.0.24'
+ gem.add_dependency 'backup', '>= 3.0.24'
+ gem.add_dependency 'fog', '~> 1.1.0' # S3
gem.add_dependency 'net-ssh', '~> 2.3.0'
gem.add_dependency 'net-sftp', '~> 2.0.5'
gem.add_dependency 'mail', '~> 2.4.0'
View
3  examples/backup
@@ -0,0 +1,3 @@
+# Put this file in rails_project/script/backup
+#!/bin/bash
+backup perform --trigger mmmenu --config_file config/backup.rb --data-path db --log-path log --tmp-path tmp
View
80 examples/backup.rb
@@ -0,0 +1,80 @@
+# encoding: utf-8
+
+# Put this file in rails_project/config/backup.rb
+
+# This is the backup gem config file. Run it from the Rails root using:
+# backup perform --trigger your_project --config_file config/backup.rb --data-path db --log-path log --tmp-path tmp
+
+# Read production db config from Rails app.
+require 'yaml'
+RAILS_ENV = ENV['RAILS_ENV'] || 'development'
+APP_ROOT = File.expand_path('..', File.dirname(__FILE__))
+APP_DB_CONFIG = YAML.load_file(File.join(APP_ROOT, '/config/database.yml'))[RAILS_ENV]
+
+##
+# Backup Generated: my_backup
+# Once configured, you can run the backup with the following command:
+#
+# $ backup perform -t my_backup [-c <path_to_configuration_file>]
+#
+Backup::Model.new(:your_project, 'Backup of YourProject DB and Assets') do
+ ##
+ # Split [Splitter]
+ #
+ # Split the backup file in to chunks of 250 megabytes
+ # if the backup file size exceeds 250 megabytes
+ #
+ split_into_chunks_of 250
+
+ ##
+ # MySQL [Database]
+ #
+ database MySQL do |db|
+ # To dump all databases, set `db.name = :all` (or leave blank)
+ db.name = APP_DB_CONFIG['database']
+ db.username = APP_DB_CONFIG['username']
+ db.password = APP_DB_CONFIG['password']
+ db.host = "localhost"
+ db.port = 3306
+ # db.socket = "/tmp/mysql.sock"
+ # Note: when using `skip_tables` with the `db.name = :all` option,
+ # table names should be prefixed with a database name.
+ # e.g. ["db_name.table_to_skip", ...]
+ # db.skip_tables = ["skip", "these", "tables"]
+ # db.only_tables = ["only", "these" "tables"]
+ db.additional_options = ["--quick", "--single-transaction"]
+ # Optional: Use to set the location of this utility
+ # if it cannot be found by name in your $PATH
+ # db.mysqldump_utility = "/opt/local/bin/mysqldump"
+ # db.mysqldump_utility = "/usr/local/mysql-5.5.15-osx10.6-x86_64/bin/mysqldump"
+ end
+
+ store_with SFTP, "YourServer" do |server|
+ server.username = 'user'
+ # server.password = 'secret'
+ server.ip = 'your_server.nl'
+ server.port = 22
+ server.path = '~/backups'
+ server.keep = 5
+ end
+
+ ##
+ # Gzip [Compressor]
+ #
+ # compress_with Gzip
+
+ notify_by Mail do |mail|
+ mail.on_success = false
+ mail.on_warning = true
+ mail.on_failure = true
+
+ mail.delivery_method = :sendmail
+ mail.from = 'no-reply@your_project.com'
+ mail.to = 'your@email.com'
+
+ # optional settings:
+ # mail.sendmail # the full path to the `sendmail` program
+ # mail.sendmail_args # string of arguments to to pass to `sendmail`
+ end
+
+end
View
17 examples/schedule.rb
@@ -0,0 +1,17 @@
+ # env :PATH, ENV['PATH'] # '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin'
+# env :RAILS_ENV, ENV['RAILS_ENV']
+# env :HOME, ENV['HOME']
+# env :SHELL, ENV['SHELL']
+
+env :MAILTO, 'your@email.com'
+
+set :output, {:error => 'log/cron_error.log', :standard => '/dev/null'}
+job_type :script, "cd :path && RAILS_ENV=:environment bundle exec script/:task :output"
+
+# Backup using the RAILS_ROOT/config/backup.rb backup gem script.
+# Schedule it using:
+# whenever
+every 1.day, :at => '2:30 am' do
+# every 1.minute do
+ script 'backup'
+end
View
1  lib/backup_rails.rb
@@ -2,4 +2,5 @@
module BackupRails
# Your code goes here...
+ # FIXME: Not needed?
end
View
2  lib/backup_rails/version.rb
@@ -1,3 +1,3 @@
module BackupRails
- VERSION = "0.0.1"
+ VERSION = "0.0.3"
end

No commit comments for this range

Something went wrong with that request. Please try again.