capistrano_transmit 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +50 -0
- data/Rakefile +12 -0
- data/capistrano_transmit.gemspec +33 -0
- data/lib/capistrano/transmit.rb +53 -0
- metadata +76 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 [name of plugin creator]
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
= Capistrano Transmit
|
2
|
+
|
3
|
+
Rails tasks to work with production data and assets.
|
4
|
+
|
5
|
+
This Ruby on Rails plugin allows you to fetch the production database and
|
6
|
+
assets and store them in your local development environment. For reasonably
|
7
|
+
sized projects, you should do this regularly since you will notice typical
|
8
|
+
production-related slowdowns such as missing indexes. The task to fetch
|
9
|
+
assets helps keep your images un-broken, which is always nice.
|
10
|
+
|
11
|
+
The only thing this plugin does, is extend Capistrano. No Rails code is loaded.
|
12
|
+
Capistrano loads the scripts in the recipes directory, and that's just what we
|
13
|
+
need.
|
14
|
+
|
15
|
+
The plugin uses rsync to transfer the files, which means any existing files are
|
16
|
+
skipped and/or appended based on their checksum. The transfers are compressed
|
17
|
+
as well so we don't need to gzip the contents first. All this assumes both your
|
18
|
+
production and development environment are Unix. Tested on Linux production and
|
19
|
+
Mac OS X development.
|
20
|
+
|
21
|
+
== Installation
|
22
|
+
|
23
|
+
ruby script/plugin install git://github.com/tilsammans/capistrano_transmit.git
|
24
|
+
|
25
|
+
or in your +Gemfile+:
|
26
|
+
|
27
|
+
gem 'capistrano_transmit'
|
28
|
+
|
29
|
+
Then add to your deploy.rb:
|
30
|
+
|
31
|
+
require 'capistrano/transmit'
|
32
|
+
|
33
|
+
== Examples
|
34
|
+
|
35
|
+
cap transmit:get:mysql # Fetch the remote production MySQL database
|
36
|
+
# and overwrite your local development database with it
|
37
|
+
cap transmit:get:assets # Fetch the remote assets into your local development environment
|
38
|
+
|
39
|
+
|
40
|
+
cap transmit:put:mysql # Overwrite the production MySQL database with your development data
|
41
|
+
|
42
|
+
== Prerequisites
|
43
|
+
|
44
|
+
This Capistrano extension assumes some variables are present in your deploy.rb:
|
45
|
+
|
46
|
+
user # the SSH user for connecting to the deploy host
|
47
|
+
deploy_host # the host on which to run the db dump
|
48
|
+
|
49
|
+
|
50
|
+
Copyright (c) 2010 Joost Baaij, released under the MIT license
|
data/Rakefile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'echoe'
|
4
|
+
|
5
|
+
Echoe.new('capistrano_transmit', '0.1.0') do |p|
|
6
|
+
p.summary = "Copies mysql databases between remote production and local development servers."
|
7
|
+
p.url = "http://github.com/tilsammans/capistrano_transmit"
|
8
|
+
p.author = "Joost Baaij"
|
9
|
+
p.email = "joost@spacebabies.nl"
|
10
|
+
p.runtime_dependencies = ["capistrano"]
|
11
|
+
p.development_dependencies = []
|
12
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{capistrano_transmit}
|
5
|
+
s.version = "0.1.0"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Joost Baaij"]
|
9
|
+
s.date = %q{2011-07-21}
|
10
|
+
s.description = %q{Copies mysql databases between remote production and local development servers.}
|
11
|
+
s.email = %q{joost@spacebabies.nl}
|
12
|
+
s.extra_rdoc_files = ["README.rdoc", "lib/capistrano/transmit.rb"]
|
13
|
+
s.files = ["MIT-LICENSE", "README.rdoc", "Rakefile", "lib/capistrano/transmit.rb", "capistrano_transmit.gemspec"]
|
14
|
+
s.homepage = %q{http://github.com/tilsammans/capistrano_transmit}
|
15
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Capistrano_transmit", "--main", "README.rdoc"]
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
s.rubyforge_project = %q{capistrano_transmit}
|
18
|
+
s.rubygems_version = %q{1.3.7}
|
19
|
+
s.summary = %q{Copies mysql databases between remote production and local development servers.}
|
20
|
+
|
21
|
+
if s.respond_to? :specification_version then
|
22
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
23
|
+
s.specification_version = 3
|
24
|
+
|
25
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
26
|
+
s.add_runtime_dependency(%q<capistrano>, [">= 0"])
|
27
|
+
else
|
28
|
+
s.add_dependency(%q<capistrano>, [">= 0"])
|
29
|
+
end
|
30
|
+
else
|
31
|
+
s.add_dependency(%q<capistrano>, [">= 0"])
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
unless Capistrano::Configuration.respond_to?(:instance)
|
2
|
+
abort "capistrano/transmit requires Capistrano 2"
|
3
|
+
end
|
4
|
+
|
5
|
+
Capistrano::Configuration.instance.load do
|
6
|
+
after "transmit:get:mysql", "transmit:cleanup"
|
7
|
+
after "transmit:put:mysql", "transmit:cleanup"
|
8
|
+
|
9
|
+
namespace :transmit do
|
10
|
+
namespace :get do
|
11
|
+
desc 'Fetch the remote production database and overwrite your local development database with it'
|
12
|
+
task :mysql, :roles => :db do
|
13
|
+
run "mysqldump --opt --quick --extended-insert --skip-lock-tables -u #{db_remote['username']} --password='#{db_remote['password']}' --host='#{db_remote['host']}' #{db_remote['database']} | gzip > #{dumpfile}"
|
14
|
+
|
15
|
+
system "rsync -vP #{user}@#{deploy_host}:#{dumpfile} tmp/#{db_local["database"]}.sql.gz"
|
16
|
+
system "gunzip < tmp/#{db_local["database"]}.sql.gz | mysql -u #{db_local['username']} --password='#{db_local['password']}' --host='#{db_local['host']}' #{db_local['database']}"
|
17
|
+
end
|
18
|
+
|
19
|
+
desc 'Fetch the assets from the production server to the development environment'
|
20
|
+
task :assets, :roles => :app do
|
21
|
+
system "rsync -Lcrvz #{user}@#{deploy_host}:#{current_path}/public ."
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
namespace :put do
|
26
|
+
desc 'Upload the local development database to the remote production database and overwrite it'
|
27
|
+
task :mysql, :roles => :db do
|
28
|
+
system "mysqldump --opt -u #{db_local['username']} --password='#{db_local['password']}' --host='#{db_local['host']}' #{db_local['database']} > tmp/#{db_local['database']}.sql"
|
29
|
+
|
30
|
+
system "rsync -vP tmp/#{db_local['database']}.sql #{user}@#{deploy_host}:#{dumpfile}"
|
31
|
+
run "mysql -u #{db_remote['username']} --password='#{db_remote['password']}' --host='#{db_remote['host']}' #{db_remote['database']} < #{dumpfile}"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
task :cleanup do
|
36
|
+
run "rm #{dumpfile}"
|
37
|
+
system "rm tmp/#{db_local['database']}.sql.gz"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
set(:db_remote) do
|
42
|
+
db_config = capture "cat #{current_path}/config/database.yml"
|
43
|
+
YAML::load(db_config)['production']
|
44
|
+
end
|
45
|
+
|
46
|
+
set(:db_local) do
|
47
|
+
YAML::load_file("config/database.yml")['development']
|
48
|
+
end
|
49
|
+
|
50
|
+
set :dumpfile do
|
51
|
+
"#{current_path}/tmp/#{db_remote['database']}.sql.gz"
|
52
|
+
end
|
53
|
+
end
|
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano_transmit
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.0
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Joost Baaij
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-07-21 00:00:00 +02:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: capistrano
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: "0"
|
25
|
+
type: :runtime
|
26
|
+
version_requirements: *id001
|
27
|
+
description: Copies mysql databases between remote production and local development servers.
|
28
|
+
email: joost@spacebabies.nl
|
29
|
+
executables: []
|
30
|
+
|
31
|
+
extensions: []
|
32
|
+
|
33
|
+
extra_rdoc_files:
|
34
|
+
- README.rdoc
|
35
|
+
- lib/capistrano/transmit.rb
|
36
|
+
files:
|
37
|
+
- MIT-LICENSE
|
38
|
+
- README.rdoc
|
39
|
+
- Rakefile
|
40
|
+
- lib/capistrano/transmit.rb
|
41
|
+
- capistrano_transmit.gemspec
|
42
|
+
has_rdoc: true
|
43
|
+
homepage: http://github.com/tilsammans/capistrano_transmit
|
44
|
+
licenses: []
|
45
|
+
|
46
|
+
post_install_message:
|
47
|
+
rdoc_options:
|
48
|
+
- --line-numbers
|
49
|
+
- --inline-source
|
50
|
+
- --title
|
51
|
+
- Capistrano_transmit
|
52
|
+
- --main
|
53
|
+
- README.rdoc
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: "0"
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: "1.2"
|
68
|
+
requirements: []
|
69
|
+
|
70
|
+
rubyforge_project: capistrano_transmit
|
71
|
+
rubygems_version: 1.6.2
|
72
|
+
signing_key:
|
73
|
+
specification_version: 3
|
74
|
+
summary: Copies mysql databases between remote production and local development servers.
|
75
|
+
test_files: []
|
76
|
+
|