pg_backup 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -5
- data/lib/pg_backup/tasks/dump.rake +6 -4
- data/lib/pg_backup/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a7f6551d1bfdba2598c5c7bfb6da8ca6a9c1eb8
|
4
|
+
data.tar.gz: 4cb244238114d085171362bfd7664d2e066a1163
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 449bedec7cf4c1b3fb454d5b97c839fcbba0b0e10a1bec7b542a48fe414e2aeafe8e848d8b82c72a84b84bad1b566312e10329aeb5b1918d76fec1e1c23a8904
|
7
|
+
data.tar.gz: 872ebb3e397e0c380b03d20771d1c74dcdb7c36f7a491dce76a35441624cda4562d825fc0982314cdc708c6899491a5b985a0fcabbd51e763a7cd82935a2a54a
|
data/README.md
CHANGED
@@ -31,10 +31,10 @@ rake pg_backup:dump:create # create a dump from local db and save it locally
|
|
31
31
|
rake pg_backup:dump:load # import latest dump from local file into local db
|
32
32
|
```
|
33
33
|
|
34
|
-
If you want to create or load a dump file from a different directory, use the ```
|
34
|
+
If you want to create or load a dump file from a different directory or file name, use the ``` PG_DUMP_DIR ``` and/or ```PG_DUMP_FILE``` (relative to dump directory) env vars:
|
35
35
|
```
|
36
|
-
rake
|
37
|
-
rake
|
36
|
+
rake PG_DUMP_DIR=/my/dump/dir PG_DUMP_FILE=mydump.backup pg_backup:dump:create
|
37
|
+
rake PG_DUMP_DIR=/my/dump/dir PG_DUMP_FILE=mydump.backup pg_backup:dump:load
|
38
38
|
```
|
39
39
|
|
40
40
|
### Capistrano integration
|
@@ -43,7 +43,7 @@ rake DUMP_DIR=/my/dump/dir pg_backup:dump:load
|
|
43
43
|
add to your ```Capfile```
|
44
44
|
```
|
45
45
|
require "pg_backup/integration/capistrano"
|
46
|
-
|
46
|
+
```
|
47
47
|
this adds some capistrano tasks
|
48
48
|
```
|
49
49
|
cap <env> pg_backup:dump:create # creates remote dump (from remote db) in remote dir
|
@@ -52,7 +52,7 @@ cap <env> pg_backup:dump:download # downloads latest remote dump to local dir
|
|
52
52
|
cap <env> pg_backup:dump:upload # uploads latest local dump to remote dir
|
53
53
|
```
|
54
54
|
|
55
|
-
To overwrite dump directories in capistrano, place something like this in your deploy.rb or
|
55
|
+
To overwrite dump directories in capistrano, place something like this in your ```deploy.rb``` or ```<stage>.rb```
|
56
56
|
```
|
57
57
|
set :pg_backup_local_dump_dir, '/my/dump/dir'
|
58
58
|
set :pg_backup_remote_dump_dir, '/my/dump/dir'
|
@@ -5,7 +5,8 @@ namespace :pg_backup do
|
|
5
5
|
namespace :dump do
|
6
6
|
desc "Load dumped postgres backup file"
|
7
7
|
task load: :environment do
|
8
|
-
|
8
|
+
env_file_name = Rails.root.join(dump_dir, ENV.fetch("PG_BACKUP_FILE")) if ENV.fetch("PG_BACKUP_FILE", nil)
|
9
|
+
file_name = env_file_name || Dir.glob("#{Rails.root}/#{dump_dir}/*.backup").sort.last
|
9
10
|
raise "[pg_backup:dump:load] Can't find a dump file!" unless file_name
|
10
11
|
say "[pg_backup:dump:load] Loading dump file from #{file_name}..."
|
11
12
|
with_database_config do |host, db, user, pw|
|
@@ -18,16 +19,17 @@ namespace :pg_backup do
|
|
18
19
|
task create: :environment do
|
19
20
|
say "[pg_backup:dump:create] Creating dump file..."
|
20
21
|
FileUtils.mkdir_p Rails.root.join(dump_dir)
|
21
|
-
|
22
|
+
env_file_name = Rails.root.join(dump_dir, ENV.fetch("PG_BACKUP_FILE")) if ENV.fetch("PG_BACKUP_FILE", nil)
|
23
|
+
file_name = env_file_name || Rails.root.join(dump_dir, "dump-#{Time.now.strftime('%Y%m%d%H%M%S')}.backup")
|
22
24
|
with_database_config do |host, db, user, pw|
|
23
25
|
` PGPASSWORD=#{pw} pg_dump --host #{host} --username #{user} --clean --format=c --no-owner --no-acl #{db} > #{file_name} `
|
24
26
|
end
|
25
|
-
say "[pg_backup:dump:create] New dump file located at #{file_name}
|
27
|
+
say "[pg_backup:dump:create] New dump file located at #{file_name}"
|
26
28
|
say "[pg_backup:dump:create] Done."
|
27
29
|
end
|
28
30
|
|
29
31
|
def dump_dir
|
30
|
-
ENV["
|
32
|
+
ENV["PG_DUMP_DIR"] || "dump" # default to 'dump' folder as dump dir
|
31
33
|
end
|
32
34
|
|
33
35
|
def say(text)
|
data/lib/pg_backup/version.rb
CHANGED
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.
|
4
|
+
version: 0.2.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-
|
11
|
+
date: 2017-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|