postmodern 0.0.5 → 0.0.6
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.
- checksums.yaml +4 -4
- data/README.md +37 -2
- data/bin/pg_wal_archive +7 -5
- data/bin/pg_wal_restore +9 -1
- data/lib/postmodern/version.rb +1 -1
- data/spec/bin/pg_wal_archive_spec.rb +6 -6
- data/spec/bin/pg_wal_restore_spec.rb +9 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6751185ec42ad83428d20347ec925ecca99080a
|
4
|
+
data.tar.gz: e2055ed0ca440c7739ccda5d1a4e1687a64c1ef7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67846656007c0e10721af39593d07ad28fe93a15fd3a1a17f6a13874a6ea232f5fdcf14f7e508634d71453e1bd2ee06d030495d84027c44c234b6503eebd04da
|
7
|
+
data.tar.gz: db5af7acb228f891ae5e447bbb3259298308134fd8f564e97f078539fcff59c08e7ff6076e8b45d5256236edfeac1d553af762e756cdd98dedfc9572d1897da5
|
data/README.md
CHANGED
@@ -8,12 +8,47 @@ Tools for managing PostgreSQL databases.
|
|
8
8
|
## Installation
|
9
9
|
|
10
10
|
```bash
|
11
|
-
gem install postmodern
|
11
|
+
[sudo] gem install postmodern
|
12
12
|
```
|
13
13
|
|
14
|
+
As a system utility, this assumes that you are installing the gem into
|
15
|
+
the system's ruby, however that is installed.
|
16
|
+
|
14
17
|
## Usage
|
15
18
|
|
16
|
-
|
19
|
+
### WAL archives
|
20
|
+
|
21
|
+
The wal archiving scripts packaged in this gem are intended to serve as
|
22
|
+
wrappers for YOUR archiving mechanism.
|
23
|
+
|
24
|
+
In postgresql.conf
|
25
|
+
|
26
|
+
```
|
27
|
+
archive_command = 'pg_wal_archive %p %f'
|
28
|
+
```
|
29
|
+
|
30
|
+
In recovery.conf
|
31
|
+
|
32
|
+
```
|
33
|
+
restore_command = 'pg_wal_restore %p %f'
|
34
|
+
```
|
35
|
+
|
36
|
+
By default these scripts will do nothing. With the presence of local
|
37
|
+
scripts available in the path, the following variables will be
|
38
|
+
exported to the environment and the local scripts called (with arguments
|
39
|
+
preserved):
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
ENV['WAL_ARCHIVE_PATH'] = ARGV[0]
|
43
|
+
ENV['WAL_ARCHIVE_FILE'] = ARGV[1]
|
44
|
+
```
|
45
|
+
|
46
|
+
Local scripts can be written in any language. They should be able access
|
47
|
+
the relevant arguments either as $1, $2 or using the variables listed above.
|
48
|
+
|
49
|
+
`pg_wal_archive` will attempt to call a `pg_wal_archive.local` script.
|
50
|
+
`pg_wal_restore` will attempt to call a `pg_wal_restore.local` script.
|
51
|
+
|
17
52
|
|
18
53
|
## Contributing
|
19
54
|
|
data/bin/pg_wal_archive
CHANGED
@@ -7,11 +7,13 @@
|
|
7
7
|
# This script (and the local script) should be executable as the
|
8
8
|
# postgres user.
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
archive_path = ARGV[0]
|
11
|
+
archive_file = ARGV[1]
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
ENV['WAL_ARCHIVE_PATH']=archive_path # maps to %p in postgres archiving
|
14
|
+
ENV['WAL_ARCHIVE_FILE']=archive_file # maps to %f in postgres archiving
|
15
|
+
|
16
|
+
puts "Archiving file: #{archive_file}, path: #{archive_path}"
|
15
17
|
|
16
18
|
def local_script_exists?
|
17
19
|
`which pg_wal_archive.local >/dev/null 2>/dev/null`
|
@@ -19,5 +21,5 @@ def local_script_exists?
|
|
19
21
|
end
|
20
22
|
|
21
23
|
if local_script_exists?
|
22
|
-
`pg_wal_archive.local`
|
24
|
+
`pg_wal_archive.local #{archive_path} #{archive_file}`
|
23
25
|
end
|
data/bin/pg_wal_restore
CHANGED
@@ -1,10 +1,18 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
archive_path = ARGV[0]
|
4
|
+
archive_file = ARGV[1]
|
5
|
+
|
6
|
+
ENV['WAL_ARCHIVE_PATH']=archive_path # maps to %p in postgres archiving
|
7
|
+
ENV['WAL_ARCHIVE_FILE']=archive_file # maps to %f in postgres archiving
|
8
|
+
|
9
|
+
puts "Archiving file: #{archive_file}, path: #{archive_path}"
|
10
|
+
|
3
11
|
def local_script_exists?
|
4
12
|
`which pg_wal_restore.local >/dev/null 2>/dev/null`
|
5
13
|
$?.exitstatus == 0
|
6
14
|
end
|
7
15
|
|
8
16
|
if local_script_exists?
|
9
|
-
`pg_wal_restore.local #{
|
17
|
+
`pg_wal_restore.local #{archive_path} #{archive_file}`
|
10
18
|
end
|
data/lib/postmodern/version.rb
CHANGED
@@ -6,12 +6,12 @@ describe 'pg_wal_archive' do
|
|
6
6
|
double_cmd('which', exit: 1)
|
7
7
|
end
|
8
8
|
|
9
|
-
it 'exports WAL_ARCHIVE_FILE' do
|
10
|
-
expect(`bin/pg_wal_archive filename
|
9
|
+
it 'exports second argument as WAL_ARCHIVE_FILE' do
|
10
|
+
expect(`bin/pg_wal_archive filepath filename`).to include('Archiving file: filename')
|
11
11
|
end
|
12
12
|
|
13
|
-
it 'exports WAL_ARCHIVE_PATH' do
|
14
|
-
expect(`bin/pg_wal_archive filename
|
13
|
+
it 'exports first argument WAL_ARCHIVE_PATH' do
|
14
|
+
expect(`bin/pg_wal_archive filepath filename`).to include('path: filepath')
|
15
15
|
end
|
16
16
|
|
17
17
|
context 'when local script is present' do
|
@@ -24,7 +24,7 @@ describe 'pg_wal_archive' do
|
|
24
24
|
it 'calls a local file with file name and path' do
|
25
25
|
expect {
|
26
26
|
`bin/pg_wal_archive 11111 222222`
|
27
|
-
}.to shellout('pg_wal_archive.local')
|
27
|
+
}.to shellout('pg_wal_archive.local 11111 222222')
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -38,7 +38,7 @@ describe 'pg_wal_archive' do
|
|
38
38
|
it 'does nothing' do
|
39
39
|
expect {
|
40
40
|
`bin/pg_wal_archive 11111 222222`
|
41
|
-
}.not_to shellout('pg_wal_archive.local')
|
41
|
+
}.not_to shellout('pg_wal_archive.local 11111 222222')
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
@@ -3,6 +3,15 @@ require 'spec_helper'
|
|
3
3
|
describe 'pg_wal_restore' do
|
4
4
|
before do
|
5
5
|
double_cmd('pg_wal_restore.local')
|
6
|
+
double_cmd('which')
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'exports second argument as WAL_ARCHIVE_FILE' do
|
10
|
+
expect(`bin/pg_wal_restore filepath filename`).to include('Archiving file: filename')
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'exports first argument as WAL_ARCHIVE_PATH' do
|
14
|
+
expect(`bin/pg_wal_restore filepath filename`).to include('path: filepath')
|
6
15
|
end
|
7
16
|
|
8
17
|
context 'when local script exists' do
|