dumpman 1.2.7 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9da2c005f92e87d46996616037b4b570b40c0c76145e24a13f9e0273044d7a6b
4
- data.tar.gz: be18187a5fb78467bb939f5718f848988472a8d24b00ebba7baa4951d3ef71c5
3
+ metadata.gz: d345a9992461b65c538df3ae71a8f05a5e638974736a9502058ed952b99c80b4
4
+ data.tar.gz: 39166bd9c4a97d9e6240822a14479f93526cd1ccf303497714cb98cfce1713ff
5
5
  SHA512:
6
- metadata.gz: 9ab3c888440f173b054630eaaa5017a072dc0fd684e546e7c4c34d8274c43de5df4c5c4f58ffc623f43c02daa36280616a871e38a8fdd3191f966acbd4b47c7b
7
- data.tar.gz: 5b1fce2f208578bd9ae6acc0c1b4609316d5331c8623c170e5e46bda0df6e495294b2883a6f42b95bb387fb9d1f0f1c219824ebea73019eb4430357cea559c75
6
+ metadata.gz: 166f605b6b46744c70abd551ffda4226656fb16c2d4b2ac0286a6619518e4ad724ee2064f31e3ab2d0bf502a74c2e21d09c5aeaae8a3011e23a03557bd8aaa10
7
+ data.tar.gz: 6ab0e4d3b452fe9763ba7b51febbed1d750694a9ac79e30853796b8037d02f74c91c18935c61acccde85e5d6279cfe3a983ba282710b4dc85cd20023601940a7
data/.gitignore CHANGED
@@ -14,3 +14,4 @@
14
14
 
15
15
  # rspec failure tracking
16
16
  .rspec_status
17
+ *.gem
data/README.md CHANGED
@@ -1,3 +1,4 @@
1
+ [![Gem Version](https://badge.fury.io/rb/dumpman.svg)](https://badge.fury.io/rb/dumpman)
1
2
  [![Build Status](https://travis-ci.org/skcc321/dumpman.svg?branch=master)](https://travis-ci.org/skcc321/dumpman)
2
3
  [![Maintainability](https://api.codeclimate.com/v1/badges/3f69b1bb862be2a7e6ce/maintainability)](https://codeclimate.com/github/skcc321/dumpman/maintainability)
3
4
  [![Test Coverage](https://api.codeclimate.com/v1/badges/3f69b1bb862be2a7e6ce/test_coverage)](https://codeclimate.com/github/skcc321/dumpman/test_coverage)
@@ -5,6 +6,15 @@
5
6
  # Dumpman
6
7
  Dumpman gem is what you need if you have application somewhere and need to dump your DB download it and up that dump localy!
7
8
 
9
+ ### use case:
10
+ You have staging OR production server with running rails app on it.
11
+
12
+ For some reason you need DB dump from that server.
13
+
14
+ What you can do?
15
+ - Solution 1: connect to that server, make dump via CLI, download it, extract it on your loacl machine
16
+ - Solution 2: install this gem and run ```bash rake db:prod:up``` and that's it.
17
+
8
18
  ![alt text](https://farm8.staticflickr.com/7347/10602023975_fd3e5b61b7_b.jpg)
9
19
 
10
20
  ## Installation
@@ -12,7 +22,7 @@ Dumpman gem is what you need if you have application somewhere and need to dump
12
22
  Add this line to your application's Gemfile:
13
23
 
14
24
  ```ruby
15
- gem 'dumpman', git: 'git@github.com:skcc321/dumpman.git'
25
+ gem 'dumpman'
16
26
  ```
17
27
 
18
28
  Then execute:
@@ -26,7 +36,7 @@ Or install it yourself as:
26
36
  Generate default config:
27
37
 
28
38
  $ rails g dumpman
29
-
39
+
30
40
  it will create file app/config/initializers/dumpman.rb
31
41
  ```ruby
32
42
  Dumpman.setup do
@@ -57,7 +67,7 @@ Update app/config/initializers/dumpman.rb with propper settings.
57
67
 
58
68
  Now you are able to use awesome commands:
59
69
 
60
- $ rake db:prod:up
70
+ $ rake db:prod:up # makes db dump on that server, compreses it, downloads, extracts localy
61
71
  $ rake db:stage:up
62
72
  $ rake db:qa:up
63
73
  ...
data/Rakefile CHANGED
@@ -1,7 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rspec/core/rake_task"
3
3
  require "rake"
4
- require "zip"
5
4
 
6
5
  Dir[File.join(File.dirname(__FILE__),'lib/tasks/*.rake')].each { |f| load f }
7
6
 
@@ -31,7 +31,6 @@ Gem::Specification.new do |spec|
31
31
 
32
32
  spec.add_dependency 'rails', '>= 4.2.8'
33
33
  spec.add_dependency 'rake', '>= 12.1.0'
34
- spec.add_dependency 'rubyzip', '>= 1.2.1'
35
34
 
36
35
  spec.add_development_dependency 'bundler', '>= 1.15'
37
36
  spec.add_development_dependency 'mysql2'
@@ -13,7 +13,7 @@ module Dumpman
13
13
  mattr_accessor :connections
14
14
 
15
15
  @@dump_folder = '.'
16
- @@dump_file_name = 'dumpman.sql'
16
+ @@dump_file_name = 'dumpman.sql.gz'
17
17
  @@connections = []
18
18
 
19
19
  class << self
@@ -44,13 +44,5 @@ module Dumpman
44
44
  def dump_file
45
45
  File.join(dump_folder, dump_file_name)
46
46
  end
47
-
48
- def dump_zip_name
49
- "#{dump_file_name}.zip"
50
- end
51
-
52
- def dump_zip
53
- File.join(dump_folder, dump_zip_name)
54
- end
55
47
  end
56
48
  end
@@ -2,11 +2,11 @@ module Dumpman
2
2
  module Adapters
3
3
  class Mysql < Base
4
4
  def dump_cmd
5
- "MYSQL_PWD='#{password}' mysqldump -u #{username} -h #{host} #{database} > #{Dumpman.dump_file}"
5
+ "MYSQL_PWD='#{password}' mysqldump -u #{username} -h #{host} #{database} | gzip -9 > #{Dumpman.dump_file}"
6
6
  end
7
7
 
8
8
  def restore_cmd
9
- "MYSQL_PWD='#{password}' mysql -u #{username} -h #{host} #{database} < #{Dumpman.dump_file}"
9
+ "gunzip < #{Dumpman.dump_file} | MYSQL_PWD='#{password}' mysql -u #{username} -h #{host} #{database}"
10
10
  end
11
11
 
12
12
  def drop_cmd
@@ -2,11 +2,11 @@ module Dumpman
2
2
  module Adapters
3
3
  class Pg < Base
4
4
  def dump_cmd
5
- "PGPASSWORD='#{password}' pg_dump -h #{host} --username '#{username}' --verbose --clean --no-owner --no-acl --format=c #{database} > '#{Dumpman.dump_file}'"
5
+ "PGPASSWORD='#{password}' pg_dump -h #{host} --username '#{username}' --verbose --clean --no-owner --no-acl -Z4 -Fc #{database} > '#{Dumpman.dump_file}'"
6
6
  end
7
7
 
8
8
  def restore_cmd
9
- "PGPASSWORD='#{password}' pg_restore -h #{host} --username '#{username}' --verbose --clean --no-owner --no-acl -d #{database} '#{Dumpman.dump_file}'"
9
+ "PGPASSWORD='#{password}' pg_restore -h #{host} --username '#{username}' --verbose --clean --no-owner --no-acl -j 4 -d #{database} '#{Dumpman.dump_file}'"
10
10
  end
11
11
 
12
12
  def drop_cmd
@@ -1,30 +1,7 @@
1
- require "zip"
2
-
3
1
  module Dumpman
4
2
  module Commandor
5
3
  extend self
6
4
 
7
- def zip
8
- # clean up from old dump
9
- File.delete(Dumpman.dump_zip) if File.exists?(Dumpman.dump_zip)
10
-
11
- Zip::File.open(Dumpman.dump_zip, Zip::File::CREATE) do |zipfile|
12
- zipfile.add(Dumpman.dump_file_name, Dumpman.dump_folder + '/' + Dumpman.dump_file_name)
13
- end
14
- end
15
-
16
- def unzip
17
- # clean up from old zip
18
- File.delete(Dumpman.dump_file) if File.exists?(Dumpman.dump_file)
19
-
20
- Zip::File.open(Dumpman.dump_zip) do |zip_file|
21
- zip_file.each do |entry|
22
- puts "Extracting #{entry.name}"
23
- entry.extract(Dumpman.dump_file)
24
- end
25
- end
26
- end
27
-
28
5
  def dump
29
6
  Dumpman::Database.dump
30
7
  end
@@ -19,11 +19,11 @@ module Dumpman
19
19
  private
20
20
 
21
21
  def compress_dump_remotely
22
- "ssh #{ssh_opts} #{ssh_cmd} 'cd #{app_path} && bash --login -c \"RAILS_ENV=#{app_env} bundle exec rake db:compress\"'"
22
+ "ssh #{ssh_opts} #{ssh_cmd} 'cd #{app_path} && bash --login -c \"RAILS_ENV=#{app_env} bundle exec rake db:dump\"'"
23
23
  end
24
24
 
25
25
  def fetch_dump_to_local
26
- "scp #{ssh_opts} #{ssh_cmd}:#{app_path}/#{Dumpman.dump_zip_name} #{Dumpman.dump_folder}/"
26
+ "scp #{ssh_opts} #{ssh_cmd}:#{app_path}/#{Dumpman.dump_file_name} #{Dumpman.dump_folder}/"
27
27
  end
28
28
  end
29
29
  end
@@ -1,3 +1,3 @@
1
1
  module Dumpman
2
- VERSION = '1.2.7'
2
+ VERSION = '1.3.0'
3
3
  end
@@ -1,4 +1,3 @@
1
- require 'zip'
2
1
  require 'dumpman'
3
2
 
4
3
  namespace :db do
@@ -18,23 +17,11 @@ namespace :db do
18
17
  desc 'up LOCAL dump'
19
18
  task :up => :environment do
20
19
  Dumpman::Executor.rake(
21
- :extract,
20
+ :restore,
22
21
  :migrate
23
22
  )
24
23
  end
25
24
 
26
- desc 'zips the database'
27
- task :compress => :environment do
28
- Dumpman::Commandor.dump
29
- Dumpman::Commandor.zip
30
- end
31
-
32
- desc 'unzips the database'
33
- task :extract => :environment do
34
- Dumpman::Commandor.unzip
35
- Dumpman::Commandor.restore
36
- end
37
-
38
25
  desc 'dumps the database'
39
26
  task :dump => :environment do
40
27
  Dumpman::Commandor.dump
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dumpman
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.7
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - rafael
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-12-27 00:00:00.000000000 Z
11
+ date: 2019-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 12.1.0
41
- - !ruby/object:Gem::Dependency
42
- name: rubyzip
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: 1.2.1
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: 1.2.1
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: bundler
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -345,8 +331,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
345
331
  - !ruby/object:Gem::Version
346
332
  version: '0'
347
333
  requirements: []
348
- rubyforge_project:
349
- rubygems_version: 2.7.6
334
+ rubygems_version: 3.0.3
350
335
  signing_key:
351
336
  specification_version: 4
352
337
  summary: gem for playing with dumps