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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d013705c58d3482656ad333f0076fb2a05ed88fe
4
- data.tar.gz: 31856208b6be6e7e39c5366dc04ffea60f06143f
3
+ metadata.gz: b6751185ec42ad83428d20347ec925ecca99080a
4
+ data.tar.gz: e2055ed0ca440c7739ccda5d1a4e1687a64c1ef7
5
5
  SHA512:
6
- metadata.gz: 15b9cd5442b710534d42e67d9511a2abf2ddf93b5a26bd5bd4bf3de6612a4397c1759d8c2a8750466abd87e74fde6550dba497223a73cebdc2464205edd6a3a3
7
- data.tar.gz: 12e4927b7fac0afe85b06785ca6ba7a9ed01200efdcb1244d7b931e4ab619dd46166e6b629c8318ff531ff8a0af3c5b182673895caac57eb68548e338e76ed47
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
- TBD
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
- ENV['WAL_ARCHIVE_FILE']=ARGV[0] # maps to %f in postgres archiving
11
- ENV['WAL_ARCHIVE_PATH']=ARGV[1] # maps to %p in postgres archiving
10
+ archive_path = ARGV[0]
11
+ archive_file = ARGV[1]
12
12
 
13
- puts "Archiving file: #{ENV['WAL_ARCHIVE_FILE']}"
14
- puts "Archiving path: #{ENV['WAL_ARCHIVE_PATH']}"
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 #{ARGV[0]} #{ARGV[1]}`
17
+ `pg_wal_restore.local #{archive_path} #{archive_file}`
10
18
  end
@@ -1,3 +1,3 @@
1
1
  module Postmodern
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -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 filepath`).to include('Archiving file: 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 filepath`).to include('Archiving path: filepath')
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postmodern
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Saxby