pg_backup 0.2.2 → 0.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
  SHA1:
3
- metadata.gz: c8af56d1b65118f8aa9b6a5ad0c3b97b061f1068
4
- data.tar.gz: 02bfc00a354b6af4257869d6ffd3d09d75ababaa
3
+ metadata.gz: 1c70029ab8d41020559601504b50cc231d68161d
4
+ data.tar.gz: c9e0a8194b4c28a0e4c0f5b0fb769286ca9406e7
5
5
  SHA512:
6
- metadata.gz: 62a946f1a796e475019242bffa5079c5b5d9ff0733ddd2ad8afa5583f07fb64b5c1398c6391aadeed6e814b2d80447bd7bd11b0a82b1bc53829cc70c5d7062cc
7
- data.tar.gz: 218f213b67533a2958c7e5867637be73ee4ce60b9a91413b9d04f5ff3e73ddcca5f6bf4a34f7363234624b12bdcfcba940dc2b80348585bc61cbb5b2c7bd0a83
6
+ metadata.gz: 1e21900d18019c6c667926f9cb55dd8d550b8a2691289f704e4c34251be108e97eaf529053b6bd9807a1a99a4d2f86a8e220e4aafb57fb453136041fcf563b28
7
+ data.tar.gz: 6a97f26e859b101dde40bbf3fc4e5f6351f4c7b4df44c524d1899caf9dbc9c365e7063a3d87be9920878973720648e60b393ec7a4fa6f568364181b41fd342e3
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # PgBackup
1
+ # pg_backup
2
2
 
3
3
  ## create and restore postgres dumps with capistrano
4
4
 
@@ -7,16 +7,16 @@
7
7
  This gem adds rake tasks to your rails application for creating and restoring postgres dumps. The dumps are created with ```pg_dump``` and restored with ```pg_restore``` - these tools are included in a full postgres installation, but also available as standalone binaries (needed if your db is not located in the application server).
8
8
 
9
9
  ## Requirements
10
- ```
11
- rails
12
- capistrano # optional
13
- ```
10
+ - rails >= 3
11
+ - capistrano (optional)
12
+ - postgresql with ```pg_dump``` and ```pg_restore``` binaries
14
13
 
15
14
  ## Installation
16
15
 
17
16
  Add this line to your application's Gemfile:
18
17
 
19
18
  ```ruby
19
+ # Gemfile
20
20
  gem 'pg_backup'
21
21
  ```
22
22
 
@@ -41,7 +41,8 @@ rake PG_DUMP_DIR=/my/dump/dir PG_DUMP_FILE=mydump.backup pg_backup:dump:load
41
41
  (https://github.com/capistrano/capistrano)
42
42
 
43
43
  add to your ```Capfile```
44
- ```
44
+ ```ruby
45
+ # Capfile
45
46
  require "pg_backup/integration/capistrano"
46
47
  ```
47
48
  this adds some capistrano tasks
@@ -50,10 +51,17 @@ cap <env> pg_backup:dump:create # creates remote dump (from remote db) in rem
50
51
  cap <env> pg_backup:dump:load # imports latest remote dump into remote db
51
52
  cap <env> pg_backup:dump:download # downloads latest remote dump to local dir
52
53
  cap <env> pg_backup:dump:upload # uploads latest local dump to remote dir
54
+ cap <env> pg_backup:dump:list # shows list of dumps in remote dir
53
55
  ```
54
56
 
55
- To overwrite dump directories in capistrano, place something like this in your ```deploy.rb``` or ```<stage>.rb```
57
+ **NOTE:** Ensure environment variable set in capistrano files (needed for pg_backup to use correct database).
58
+ ```ruby
59
+ # staging.rb
60
+ set :environment, 'staging'
56
61
  ```
62
+
63
+ To overwrite dump directories in capistrano, place something like this in your ```deploy.rb``` or ```<stage>.rb```
64
+ ```ruby
57
65
  set :pg_backup_local_dump_dir, '/my/dump/dir'
58
66
  set :pg_backup_remote_dump_dir, '/my/dump/dir'
59
67
  ```
@@ -63,10 +71,22 @@ set :pg_backup_remote_dump_dir, '/my/dump/dir'
63
71
 
64
72
  add to your ```Capfile```
65
73
 
66
- ```
74
+ ```ruby
75
+ # Capfile
67
76
  require "pg_backup/integration/deploy_mate"
68
77
  ```
69
78
 
79
+ ## Example usage
80
+
81
+ Create a dump on production server, download it, upload the dump to prestage and load it into prestage database
82
+
83
+ ```
84
+ bundle exec cap production pg_backup:dump:create
85
+ bundle exec cap production pg_backup:dump:download
86
+ bundle exec cap prestage pg_backup:dump:upload
87
+ bundle exec cap prestage pg_backup:dump:load
88
+ ```
89
+
70
90
  ## Credits
71
91
  https://gist.github.com/hopsoft/56ba6f55fe48ad7f8b90
72
92
 
@@ -71,5 +71,21 @@ namespace :pg_backup do
71
71
  end
72
72
  end
73
73
  end
74
+
75
+ desc "List remote db dumps"
76
+ task :list do
77
+ on roles(:app) do
78
+ within current_path do
79
+ with rails_env: fetch(:environment) do
80
+ if !test("[ -d #{shared_path}/#{fetch(:pg_backup_remote_dump_dir)} ]")
81
+ error "Folder '#{shared_path}/#{fetch(:pg_backup_remote_dump_dir)}' does not exits!"
82
+ else
83
+ info "List of dumps in '#{shared_path}/#{fetch(:pg_backup_remote_dump_dir)}'"
84
+ execute "ls -lh #{shared_path}/#{fetch(:pg_backup_remote_dump_dir)}"
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end
74
90
  end
75
91
  end
@@ -1,3 +1,3 @@
1
1
  module PgBackup
2
- VERSION = "0.2.2".freeze
2
+ VERSION = "0.3.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_backup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcus Geissler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-03 00:00:00.000000000 Z
11
+ date: 2017-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -96,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
96
  version: '0'
97
97
  requirements: []
98
98
  rubyforge_project:
99
- rubygems_version: 2.5.1
99
+ rubygems_version: 2.4.5.1
100
100
  signing_key:
101
101
  specification_version: 4
102
102
  summary: Create, restore, download and upload postgres dumps locally and on remote