Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Iliya Manolov
slapos
Commits
e79a64f2
Commit
e79a64f2
authored
Jun 26, 2014
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
abilian: postgres basebackup
parent
f8a696aa
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
91 additions
and
5 deletions
+91
-5
software/abilian/extranet_spr/instance-postgres.cfg.in
software/abilian/extranet_spr/instance-postgres.cfg.in
+85
-3
software/abilian/extranet_spr/instance.cfg.in
software/abilian/extranet_spr/instance.cfg.in
+4
-0
software/abilian/extranet_spr/software.cfg
software/abilian/extranet_spr/software.cfg
+2
-2
No files found.
software/abilian/extranet_spr/instance-postgres.cfg.in
View file @
e79a64f2
...
@@ -28,8 +28,8 @@ superuser = postgres
...
@@ -28,8 +28,8 @@ superuser = postgres
password = $${postgres-passwd:passwd}
password = $${postgres-passwd:passwd}
port = 5432
port = 5432
dbname = db
dbname = db
# pgdata
_directory is created by initdb, and should not exist beforehand
.
# pgdata
-directory is created by initdb, and should not exist beforehand. Mandatory parameter
.
pgdata-directory = $${directories:var}/data
pgdata-directory = $${directories:var}/
pg
data
bin = ${postgresql91:location}/bin
bin = ${postgresql91:location}/bin
services = $${directories:services}
services = $${directories:services}
...
@@ -48,6 +48,10 @@ template-postgresql-conf =
...
@@ -48,6 +48,10 @@ template-postgresql-conf =
default_text_search_config = 'pg_catalog.english'
default_text_search_config = 'pg_catalog.english'
unix_socket_directory = '{unix_socket_directory}'
unix_socket_directory = '{unix_socket_directory}'
unix_socket_permissions = 0700
unix_socket_permissions = 0700
# backup
wal_level = hot_standby
max_wal_senders = 2
template-pg-hba-conf =
template-pg-hba-conf =
# This configuration file is generated by a SlapOS instance profile. Manual edits will be overwritten.
# This configuration file is generated by a SlapOS instance profile. Manual edits will be overwritten.
...
@@ -57,6 +61,7 @@ template-pg-hba-conf =
...
@@ -57,6 +61,7 @@ template-pg-hba-conf =
#do not conflict with other postgres instances on the same node
#do not conflict with other postgres instances on the same node
#host all all 127.0.0.1/32 md5
#host all all 127.0.0.1/32 md5
{ipv4_auth}
{ipv4_auth}
local replication postgres trust
template-hba-ipv4 =
template-hba-ipv4 =
host all all {ip}/32 md5
host all all {ip}/32 md5
...
@@ -97,18 +102,95 @@ key = $${slap-connection:key-file}
...
@@ -97,18 +102,95 @@ key = $${slap-connection:key-file}
cert = $${slap-connection:cert-file}
cert = $${slap-connection:cert-file}
#[postgres-backup-sql]
#recipe = slapos.recipe.template:jinja2
#template = inline:
# #!/bin/bash
# . {{environment}}
# {{postgres_bin}}/pg_dumpall --clean --file=$${directories:backup}/dumpall
# echo "backup done"
#rendered = $${directories:bin}/postgres-backup
#mode = 700
#context =
# raw environment $${buildout:directory}/environment.sh
# raw postgres_bin $${postgres-instance:bin}
[postgres-status]
recipe = slapos.recipe.template:jinja2
template = inline:
#!/bin/sh
extranet_part=`pwd | grep -o slappart[0-9+] | tail -1`
/opt/slapos/bin/slapos node supervisorctl --cfg ../../../../etc/slapos.cfg status $extranet_part:postgres-start-on-watch
rendered = $${directories:bin}/postgres-status
mode = 700
[postgres-stop]
recipe = slapos.recipe.template:jinja2
template = inline:
#!/bin/sh
extranet_part=`pwd | grep -o slappart[0-9+] | tail -1`
/opt/slapos/bin/slapos node supervisorctl --cfg ../../../../etc/slapos.cfg stop $extranet_part:postgres-start-on-watch
rendered = $${directories:bin}/postgres-stop
mode = 700
[postgres-start]
recipe = slapos.recipe.template:jinja2
template = inline:
#!/bin/sh
extranet_part=`pwd | grep -o slappart[0-9+] | tail -1`
/opt/slapos/bin/slapos node supervisorctl --cfg ../../../../etc/slapos.cfg start $extranet_part:postgres-start-on-watch
rendered = $${directories:bin}/postgres-start
mode = 700
[postgres-restore]
recipe = slapos.recipe.template:jinja2
template = inline:
#!/bin/bash
. {{environment}}
# shut down postgres
$${directories:bin}/postgres-stop
# check that postgres is down or refuse to run
$${directories:bin}/postgres-status | grep STOPPED || exit 10
echo "restoring from {{backup_dir}}"
rm -rf {{pgdata}}/pg_* {{pgdata}}/base {{pgdata}}/global {{pgdata}}/PG_VERSION
cp -a {{backup_dir}}/pg_* {{backup_dir}}/base {{backup_dir}}/global {{backup_dir}}/PG_VERSION {{pgdata}}/
echo "restore done"
echo "SELECT 1" | postgres --single -D {{pgdata}} {{dbname}} || (rm {{pgdata}}/postmaster.pid; pg_resetxlog -f {{pgdata}})
for table in blob partenaire contact visite; do
echo "COPY (SELECT COUNT(*) FROM $table) To '{{pgdata}}/$table.count' (format csv, delimiter ';')" | postgres --single -D {{pgdata}} {{dbname}}
done
rendered = $${directories:bin}/postgres-restore
mode = 700
context =
raw dbname extranet_spr_production
raw environment $${buildout:directory}/environment.sh
raw postgres_bin $${postgres-instance:bin}
raw pgdata $${postgres-instance:pgdata-directory}
raw backup_dir $${directories:backup}
[postgres-backup]
[postgres-backup]
recipe = slapos.recipe.template:jinja2
recipe = slapos.recipe.template:jinja2
template = inline:
template = inline:
#!/bin/bash
#!/bin/bash
. {{environment}}
. {{environment}}
{{postgres_bin}}/pg_dumpall --clean --file=$${directories:backup}/dumpall
rm -rf {{backup_dir}}
{{postgres_bin}}/pg_basebackup -D {{backup_dir}} -x -U postgres
echo "backup done"
echo "backup done"
rendered = $${directories:bin}/postgres-backup
rendered = $${directories:bin}/postgres-backup
mode = 700
mode = 700
context =
context =
raw environment $${buildout:directory}/environment.sh
raw environment $${buildout:directory}/environment.sh
raw postgres_bin $${postgres-instance:bin}
raw postgres_bin $${postgres-instance:bin}
raw backup_dir $${directories:backup}
[cron-postgres-backup]
[cron-postgres-backup]
...
...
software/abilian/extranet_spr/instance.cfg.in
View file @
e79a64f2
...
@@ -26,6 +26,10 @@ parts =
...
@@ -26,6 +26,10 @@ parts =
redis
redis
cron
cron
postgres-backup
postgres-backup
postgres-restore
postgres-start
postgres-stop
postgres-status
cron-postgres-backup
cron-postgres-backup
...
...
software/abilian/extranet_spr/software.cfg
View file @
e79a64f2
...
@@ -239,14 +239,14 @@ configure-command =
...
@@ -239,14 +239,14 @@ configure-command =
recipe = slapos.recipe.template
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance.cfg.in
url = ${:_profile_base_location_}/instance.cfg.in
output = ${buildout:directory}/instance.cfg
output = ${buildout:directory}/instance.cfg
md5sum =
6aaed03a96475027eff404c430d7888f
md5sum =
02e0a25e4ffdb63a18cc29d0c9055919
mode = 0644
mode = 0644
[instance-postgres]
[instance-postgres]
recipe = slapos.recipe.template
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-postgres.cfg.in
url = ${:_profile_base_location_}/instance-postgres.cfg.in
output = ${buildout:directory}/instance-postgres.cfg
output = ${buildout:directory}/instance-postgres.cfg
md5sum =
5fc618f929c9d34cdaca57b17864c611
md5sum =
16a2d43b29a3c497c03a496f423c1600
mode = 0644
mode = 0644
[instance-redis]
[instance-redis]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment