rails_db_dump 0.0.1

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/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in rails_db_dump.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # rails_db_dump
2
+
3
+ An install-and-forget KISSy wrapper around your database dumper.
4
+
5
+ ## Usage
6
+
7
+ rake db:dump
8
+
9
+ It has no parameters and dumps the current database to standart output.
10
+
11
+ ## Installation
12
+
13
+ Rails 3: add `gem rails_db_dump` to your Gemfile.
14
+
15
+ Rails 2.3: add the gem to your environment, then add `include 'rails_db_dump/tasks'` to your Rakefile
16
+
17
+ ## Requirements
18
+
19
+ None (except Rails, obviously). Supports MySQL, PostgreSQL, SQLite.
20
+
21
+ ## Tips
22
+
23
+ The thought behind this plugin was to do one thing and do it good, and that is reuse the existings database settings to provide database dumping functionality.
24
+
25
+ If you want a complet-er backup solution, pipe it up to `gzip` then add timestamps:
26
+
27
+ rake db:dump RAILS_ENV=production | gzip > db/backup/`date +%Y-%m-%d_%H-%M`.sql.gz
28
+
29
+ Only keep the last 5 dumps:
30
+
31
+ cd dumps && ls -t | awk 'NR>5' | xargs rm
32
+
33
+ Push'em home with `scp`:
34
+
35
+ scp -r dumps my_secure_backup_server.com:/my/backup/location
36
+
37
+ Or use `rsnapshot` to rotate backups.
38
+
39
+ * * *
40
+
41
+ © 2010 Leonid Shevtsov, released under the MIT license
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1 @@
1
+ require File.join(File.dirname(__FILE__), *%w[rails_db_dump railtie]) if defined?(::Rails::Railtie)
@@ -0,0 +1,10 @@
1
+ require 'rails_db_dump'
2
+ require 'rails'
3
+
4
+ module RailsDbDump
5
+ class Railtie < Rails::Railtie
6
+ rake_tasks do
7
+ load File.expand_path('../tasks.rb', __FILE__)
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,36 @@
1
+ namespace :db do
2
+ task :dump do
3
+ require 'yaml'
4
+ config = YAML.load_file(File.join(Rails.root,'config','database.yml'))[Rails.env]
5
+ case config["adapter"]
6
+ when /^mysql/
7
+ args = {
8
+ 'host' => '--host',
9
+ 'port' => '--port',
10
+ 'socket' => '--socket',
11
+ 'username' => '--user',
12
+ 'encoding' => '--default-character-set',
13
+ 'password' => '--password'
14
+ }.map { |opt, arg| "#{arg}=#{config[opt]}" if config[opt] }.compact
15
+ args << config['database']
16
+
17
+ exec('mysqldump', *args)
18
+
19
+ when "postgresql"
20
+ ENV['PGUSER'] = config["username"] if config["username"]
21
+ ENV['PGHOST'] = config["host"] if config["host"]
22
+ ENV['PGPORT'] = config["port"].to_s if config["port"]
23
+ ENV['PGPASSWORD'] = config["password"].to_s if config["password"]
24
+ exec('pg_dump', config["database"])
25
+
26
+ when "sqlite"
27
+ exec('sqlite', config["database"], '.dump')
28
+
29
+ when "sqlite3"
30
+ exec('sqlite3', config['database'], '.dump')
31
+
32
+ else
33
+ abort "Don't know how to dump #{config['database']}."
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,3 @@
1
+ module RailsDbDump
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "rails_db_dump/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "rails_db_dump"
7
+ s.version = RailsDbDump::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Leonid Shevtsov"]
10
+ s.email = ["leonid@shevtsov.me"]
11
+ s.homepage = "https://github.com/leonid-shevtsov/rails_db_dump"
12
+ s.summary = %q{dump your Rails database with a simple rake task}
13
+ s.description = %q{rails_db_dump is a wrapper for the native dumper of whatever database engine you're using, taking access parameters from database.yml. Supports mysql, postgresql and sqlite at the moment.}
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.require_paths = ["lib"]
19
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails_db_dump
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Leonid Shevtsov
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-12-01 00:00:00 +02:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: rails_db_dump is a wrapper for the native dumper of whatever database engine you're using, taking access parameters from database.yml. Supports mysql, postgresql and sqlite at the moment.
23
+ email:
24
+ - leonid@shevtsov.me
25
+ executables: []
26
+
27
+ extensions: []
28
+
29
+ extra_rdoc_files: []
30
+
31
+ files:
32
+ - .gitignore
33
+ - Gemfile
34
+ - README.md
35
+ - Rakefile
36
+ - lib/rails_db_dump.rb
37
+ - lib/rails_db_dump/railtie.rb
38
+ - lib/rails_db_dump/tasks.rb
39
+ - lib/rails_db_dump/version.rb
40
+ - rails_db_dump.gemspec
41
+ has_rdoc: true
42
+ homepage: https://github.com/leonid-shevtsov/rails_db_dump
43
+ licenses: []
44
+
45
+ post_install_message:
46
+ rdoc_options: []
47
+
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ hash: 3
56
+ segments:
57
+ - 0
58
+ version: "0"
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ hash: 3
65
+ segments:
66
+ - 0
67
+ version: "0"
68
+ requirements: []
69
+
70
+ rubyforge_project:
71
+ rubygems_version: 1.3.7
72
+ signing_key:
73
+ specification_version: 3
74
+ summary: dump your Rails database with a simple rake task
75
+ test_files: []
76
+