-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[bitnami/postgresql] Enable override the archive_command value in postgresql containers #51872
Closed
Alvaro-Campesino
wants to merge
3
commits into
bitnami:main
from
Alvaro-Campesino:incremental_backup
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -368,6 +368,19 @@ postgresql_create_replication_user() { | |||||||
echo "CREATE ROLE \"$POSTGRESQL_REPLICATION_USER\" REPLICATION LOGIN ENCRYPTED PASSWORD '$escaped_password'" | postgresql_execute | ||||||||
} | ||||||||
|
||||||||
######################## | ||||||||
# Change postgresql.conf by setting archive_command value | ||||||||
# Globals: | ||||||||
# POSTGRESQL_* | ||||||||
# Arguments: | ||||||||
# None | ||||||||
# Returns: | ||||||||
# None | ||||||||
######################### | ||||||||
postgresql_configure_archive_command() { | ||||||||
info "Overriding archive_command default value..." | ||||||||
postgresql_set_property "archive_command" "cp %p ${POSTGRESQL_WAL_ARCHIVE_COMMAND_DIR}/%f" | ||||||||
} | ||||||||
######################## | ||||||||
# Change postgresql.conf by setting replication parameters | ||||||||
# Globals: | ||||||||
|
@@ -614,15 +627,19 @@ postgresql_initialize() { | |||||||
ensure_dir_exists "$dir" | ||||||||
am_i_root && chown "$POSTGRESQL_DAEMON_USER:$POSTGRESQL_DAEMON_GROUP" "$dir" | ||||||||
done | ||||||||
is_empty_value "$POSTGRESQL_WAL_ARCHIVE_COMMAND_DIR" || ensure_dir_exists "$POSTGRESQL_WAL_ARCHIVE_COMMAND_DIR" && am_i_root && chown "$POSTGRESQL_DAEMON_USER:$POSTGRESQL_DAEMON_GROUP" "$POSTGRESQL_WAL_ARCHIVE_COMMAND_DIR" | ||||||||
am_i_root && find "$POSTGRESQL_DATA_DIR" -mindepth 1 -maxdepth 1 -not -name ".snapshot" -not -name "lost+found" -exec chown -R "$POSTGRESQL_DAEMON_USER:$POSTGRESQL_DAEMON_GROUP" {} \; | ||||||||
chmod u+rwx "$POSTGRESQL_DATA_DIR" || warn "Lack of permissions on data directory!" | ||||||||
chmod go-rwx "$POSTGRESQL_DATA_DIR" || warn "Lack of permissions on data directory!" | ||||||||
is_empty_value "$POSTGRESQL_WAL_ARCHIVE_COMMAND_DIR" || chmod u+rw "$POSTGRESQL_WAL_ARCHIVE_COMMAND_DIR" | ||||||||
Alvaro-Campesino marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Due to the issue mentioned above, something like this could be worth.
Suggested change
|
||||||||
|
||||||||
is_boolean_yes "$POSTGRESQL_ALLOW_REMOTE_CONNECTIONS" && is_boolean_yes "$create_pghba_file" && postgresql_create_pghba && postgresql_allow_local_connection | ||||||||
# Configure port | ||||||||
postgresql_set_property "port" "$POSTGRESQL_PORT_NUMBER" | ||||||||
is_empty_value "$POSTGRESQL_DEFAULT_TOAST_COMPRESSION" || postgresql_set_property "default_toast_compression" "$POSTGRESQL_DEFAULT_TOAST_COMPRESSION" | ||||||||
is_empty_value "$POSTGRESQL_PASSWORD_ENCRYPTION" || postgresql_set_property "password_encryption" "$POSTGRESQL_PASSWORD_ENCRYPTION" | ||||||||
# Configure WAL backup with archive_command | ||||||||
is_empty_value "$POSTGRESQL_WAL_ARCHIVE_COMMAND_DIR" || postgresql_configure_archive_command | ||||||||
if ! is_dir_empty "$POSTGRESQL_DATA_DIR"; then | ||||||||
info "Deploying PostgreSQL with persisted data..." | ||||||||
export POSTGRESQL_FIRST_BOOT="no" | ||||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we use a separate volume to store the backups, this piece of code can be removed. Adding a validation in postgresql_validate could be a good idea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have been thinking about this and even if it is a separate volume , I think it is a good idea to use
ensure_dir_exists
as for example when using variables you can set the final path in a variable (which is my current setup), in order to have each pods WAL files in a separate folder.What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case everything will work smoothly and I agree that's a good idea, you can have a shared backup volume and each container will write in its own folder.
Now if you have this set up (
POSTGRESQL_WAL_ARCHIVE_COMMAND_DIR
directly points to the volume):The container will fail because the code below will try to change volume permissions: