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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stephane VAROQUI
slapos
Commits
97e89b28
Commit
97e89b28
authored
Nov 26, 2012
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
backup postgres with custom format and no permission
parent
19a2b07e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
22 deletions
+21
-22
slapos/recipe/postgres/__init__.py
slapos/recipe/postgres/__init__.py
+16
-19
stack/lapp/buildout.cfg
stack/lapp/buildout.cfg
+1
-1
stack/lapp/postgres/instance-postgres-import.cfg.in
stack/lapp/postgres/instance-postgres-import.cfg.in
+4
-2
No files found.
slapos/recipe/postgres/__init__.py
View file @
97e89b28
...
@@ -206,26 +206,22 @@ class ExportRecipe(GenericBaseRecipe):
...
@@ -206,26 +206,22 @@ class ExportRecipe(GenericBaseRecipe):
def
install
(
self
):
def
install
(
self
):
pgdata
=
self
.
options
[
'pgdata-directory'
]
pgdata
=
self
.
options
[
'pgdata-directory'
]
ret
=
[]
wrapper
=
self
.
options
[
'wrapper'
]
wrapper
=
self
.
options
[
'wrapper'
]
self
.
createBackupScript
(
wrapper
)
self
.
createBackupScript
(
wrapper
)
ret
.
append
(
wrapper
)
return
[
wrapper
]
return
ret
def
createBackupScript
(
self
,
wrapper
):
def
createBackupScript
(
self
,
wrapper
):
"""
"""
Create a script to backup the database in
plain SQL
format.
Create a script to backup the database in
'custom'
format.
"""
"""
content
=
textwrap
.
dedent
(
"""
\
content
=
textwrap
.
dedent
(
"""
\
#!/bin/sh
#!/bin/sh
umask 077
umask 077
%(bin)s/pg_dump
\
\
%(bin)s/pg_dump
\
\
-h %(pgdata-directory)s
\
\
--host=%(pgdata-directory)s
\
\
-f %(backup-directory)s/backup.sql
\
\
--format=custom
\
\
--file=%(backup-directory)s/backup.dump
\
\
%(dbname)s
%(dbname)s
"""
%
self
.
options
)
"""
%
self
.
options
)
self
.
createExecutable
(
wrapper
,
content
=
content
)
self
.
createExecutable
(
wrapper
,
content
=
content
)
...
@@ -236,23 +232,24 @@ class ImportRecipe(GenericBaseRecipe):
...
@@ -236,23 +232,24 @@ class ImportRecipe(GenericBaseRecipe):
def
install
(
self
):
def
install
(
self
):
pgdata
=
self
.
options
[
'pgdata-directory'
]
pgdata
=
self
.
options
[
'pgdata-directory'
]
wrapper
=
self
.
options
[
'wrapper'
]
ret
=
[]
self
.
createRestoreScript
(
wrapper
)
if
not
os
.
path
.
exists
(
pgdata
):
return
[
wrapper
]
wrapper
=
self
.
options
[
'wrapper'
]
self
.
createRestoreScript
(
wrapper
)
ret
.
append
(
wrapper
)
return
ret
def
createRestoreScript
(
self
,
wrapper
):
def
createRestoreScript
(
self
,
wrapper
):
"""
"""
Create a script to
backup the database in plain SQL
format.
Create a script to
restore the database from 'custom'
format.
"""
"""
content
=
textwrap
.
dedent
(
"""
\
content
=
textwrap
.
dedent
(
"""
\
#!/bin/sh
#!/bin/sh
%(bin)s/pg_restore -h %(pgdata-directory)s -d %(dbname)s %(backup-directory)s/backup.sql
%(bin)s/pg_restore
\
\
--host=%(pgdata-directory)s
\
\
--dbname=%(dbname)s
\
\
--clean
\
\
--no-owner
\
\
--no-acl
\
\
%(backup-directory)s/backup.dump
"""
%
self
.
options
)
"""
%
self
.
options
)
self
.
createExecutable
(
wrapper
,
content
=
content
)
self
.
createExecutable
(
wrapper
,
content
=
content
)
...
...
stack/lapp/buildout.cfg
View file @
97e89b28
...
@@ -92,7 +92,7 @@ mode = 0644
...
@@ -92,7 +92,7 @@ mode = 0644
recipe = slapos.recipe.template
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/postgres/instance-postgres-import.cfg.in
url = ${:_profile_base_location_}/postgres/instance-postgres-import.cfg.in
output = ${buildout:directory}/instance-postgres-import.cfg
output = ${buildout:directory}/instance-postgres-import.cfg
md5sum =
feb43a65eefd9c5dea8e7d3551465956
md5sum =
1989ba2164dd5f79793a04e0a02ea515
mode = 0644
mode = 0644
[instance-postgres-export]
[instance-postgres-export]
...
...
stack/lapp/postgres/instance-postgres-import.cfg.in
View file @
97e89b28
...
@@ -2,11 +2,13 @@
...
@@ -2,11 +2,13 @@
extends = ${instance-postgres:output}
extends = ${instance-postgres:output}
${pbsready-import:output}
${pbsready-import:output}
parts += postgres-instance
parts +=
postgres-instance
[importer]
[importer]
recipe = slapos.cookbook:postgres.import
recipe = slapos.cookbook:postgres.import
wrapper = $${rootdirectory:bin}/
resilient
-importer
wrapper = $${rootdirectory:bin}/
$${slap-parameter:namebase}
-importer
bin = $${postgres-instance:bin}
bin = $${postgres-instance:bin}
pgdata-directory = $${postgres-instance:pgdata-directory}
pgdata-directory = $${postgres-instance:pgdata-directory}
backup-directory = $${postgres-instance:backup-directory}
backup-directory = $${postgres-instance:backup-directory}
...
...
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