capistrano-wal-e 0.1.1 → 0.1.2
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 +31 -23
- data/lib/capistrano/tasks/wal_e.rake +27 -22
- data/lib/capistrano/wal_e/version.rb +1 -1
- 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: 2457e5c70bd35faba8fe885ee1d227f57154e989
|
4
|
+
data.tar.gz: 6e72856c895517d2aeaa074ab3caf5083bc6fb91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24bba8fc8f1ab253b6a04b62a766f139e67b2a5f079da2354d91ee427cfb07ea2d6fee3bf0115505f66cb6f3abbfc657cbeebc0f9dbd34c74b12be9c9b2aef6b
|
7
|
+
data.tar.gz: b1fd3a9d70bbb2d8106fdf2d7fca185565228d0de1870f514a6fa75ea474efaf9ecae1967aefa1c0894dffbe976987f3ffd44412216cef5dcf4fca8d71817c8c
|
data/README.md
CHANGED
@@ -1,41 +1,49 @@
|
|
1
|
-
# Capistrano::
|
1
|
+
# Capistrano::UnicornNginx
|
2
2
|
|
3
|
-
|
3
|
+
Capistrano tasks for automatic and sensible WAL-E configuration
|
4
4
|
|
5
|
-
|
5
|
+
Goals of this plugin:
|
6
6
|
|
7
|
-
|
7
|
+
* automatic configuration for setting up WAL-E for continuous backups of
|
8
|
+
PostgreSQL.
|
8
9
|
|
9
|
-
|
10
|
+
Specifics:
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
```
|
14
|
-
|
15
|
-
And then execute:
|
12
|
+
* generates environment variables for WAL-e
|
13
|
+
* sets up cronjobs for base backups and deleting old ones
|
16
14
|
|
17
|
-
|
15
|
+
Almost all the setup has been done by capistrano. There is just one manual step
|
16
|
+
that needs to be done.
|
18
17
|
|
19
|
-
|
18
|
+
* Uncomment and modify these lines in your postgresql.conf file under /etc/postgresql/9.3/main/
|
20
19
|
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
```
|
21
|
+
wal_level = archive
|
22
|
+
archive_mode = on
|
23
|
+
archive_command = 'envdir /etc/wal-e.d/env /usr/local/bin/wal-e wal-push %p'
|
24
|
+
archive_timeout = 60
|
25
|
+
```
|
24
26
|
|
25
|
-
|
27
|
+
Then restart postgres: `service postgresql restart`.
|
26
28
|
|
27
|
-
|
29
|
+
* Test by making the first snapshot backup:
|
30
|
+
```
|
31
|
+
/usr/bin/envdir /etc/wal-e.d/env /usr/local/bin/wal-e backup-push /var/lib/postgresql/9.3/main
|
28
32
|
|
29
|
-
|
33
|
+
```
|
30
34
|
|
31
|
-
|
35
|
+
`capistrano-wal-e` works only with Capistrano 3!
|
32
36
|
|
33
|
-
|
37
|
+
### Installation
|
34
38
|
|
35
|
-
|
39
|
+
Add this to `Gemfile`:
|
36
40
|
|
41
|
+
group :development do
|
42
|
+
gem 'capistrano', '~> 3.2.1'
|
43
|
+
gem 'capistrano-wal-e', '~> 0.1.1'
|
44
|
+
end
|
37
45
|
|
38
|
-
|
46
|
+
And then:
|
39
47
|
|
40
|
-
|
48
|
+
$ bundle install
|
41
49
|
|
@@ -4,36 +4,41 @@ namespace :load do
|
|
4
4
|
end
|
5
5
|
end
|
6
6
|
|
7
|
-
namespace :
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
7
|
+
namespace :postgresql do
|
8
|
+
namespace :wal_e do
|
9
|
+
desc 'Setup the WAL-E environment variables'
|
10
|
+
task :setup_env do
|
11
|
+
on roles :db do |role|
|
12
|
+
sudo 'mkdir -p /etc/wal-e.d/env'
|
13
|
+
sudo_upload! StringIO.new(fetch(:aws_access_key_id)), '/etc/wal-e.d/env/AWS_ACCESS_KEY_ID'
|
14
|
+
sudo_upload! StringIO.new(fetch(:aws_secret_access_key)), '/etc/wal-e.d/env/AWS_SECRET_ACCESS_KEY'
|
15
|
+
sudo_upload! StringIO.new(fetch(:aws_region)), '/etc/wal-e.d/env/AWS_REGION'
|
16
|
+
sudo_upload! StringIO.new("#{fetch(:wale_s3_prefix)}_#{role}"), '/etc/wal-e.d/env/WALE_S3_PREFIX'
|
17
|
+
sudo 'chown -R root:postgres /etc/wal-e.d'
|
18
|
+
end
|
16
19
|
end
|
17
|
-
end
|
18
20
|
|
19
|
-
|
20
|
-
|
21
|
-
|
21
|
+
desc 'Setup the WAL-E cron jobs for backup and cleanup'
|
22
|
+
task :setup_cron do
|
23
|
+
on roles :db do
|
24
|
+
cron = <<-EOF.gsub(/^\s+/, '')
|
22
25
|
0 3 * * * /usr/bin/envdir /etc/wal-e.d/env /usr/local/bin/wal-e backup-push /var/lib/postgresql/9.3/main
|
23
26
|
0 5 * * * envdir /etc/wal-e.d/env /usr/local/bin/wal-e delete --confirm retain 5
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
27
|
+
EOF
|
28
|
+
sudo_upload! StringIO.new(cron), "#{shared_path}/postgres-cron"
|
29
|
+
sudo "chown -R root:postgres #{shared_path}/postgres-cron"
|
30
|
+
sudo "-u postgres crontab #{shared_path}/postgres-cron"
|
31
|
+
end
|
28
32
|
end
|
29
|
-
end
|
30
33
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
+
desc 'Setup WAL-E for continuous PostgreSQL backups'
|
35
|
+
task :setup do
|
36
|
+
invoke 'postgresql:wal_e:setup_env'
|
37
|
+
invoke 'postgresql:wal_e:setup_cron'
|
38
|
+
end
|
34
39
|
end
|
35
40
|
end
|
36
41
|
|
37
42
|
task :setup do
|
38
|
-
invoke 'wal_e:setup'
|
43
|
+
invoke 'postgresql:wal_e:setup'
|
39
44
|
end
|