Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion 12/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ghcr.io/bfren/alpine-s6:alpine3.18-5.4.6
FROM ghcr.io/bfren/alpine-s6:alpine3.18-5.4.7

LABEL org.opencontainers.image.source="https://github.com/bfren/docker-postgresql"

Expand Down
2 changes: 1 addition & 1 deletion 13/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ghcr.io/bfren/alpine-s6:alpine3.19-5.4.6
FROM ghcr.io/bfren/alpine-s6:alpine3.19-5.4.7

LABEL org.opencontainers.image.source="https://github.com/bfren/docker-postgresql"

Expand Down
2 changes: 1 addition & 1 deletion 14/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ghcr.io/bfren/alpine-s6:alpine3.20-5.4.6
FROM ghcr.io/bfren/alpine-s6:alpine3.20-5.4.7

LABEL org.opencontainers.image.source="https://github.com/bfren/docker-postgresql"

Expand Down
2 changes: 1 addition & 1 deletion 15/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ghcr.io/bfren/alpine-s6:alpine3.20-5.4.6
FROM ghcr.io/bfren/alpine-s6:alpine3.20-5.4.7

LABEL org.opencontainers.image.source="https://github.com/bfren/docker-postgresql"

Expand Down
2 changes: 1 addition & 1 deletion 16/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ghcr.io/bfren/alpine-s6:alpine3.20-5.4.6
FROM ghcr.io/bfren/alpine-s6:alpine3.20-5.4.7

LABEL org.opencontainers.image.source="https://github.com/bfren/docker-postgresql"

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.2.11
3.2.12
2 changes: 1 addition & 1 deletion generate-dockerfiles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -euo pipefail

docker pull bfren/alpine

BASE_VERSION="5.4.6"
BASE_VERSION="5.4.7"
echo "Base: ${BASE_VERSION}"

POSTGRESQL_VERSIONS="12 13 14 15 16"
Expand Down
1 change: 1 addition & 0 deletions overlay/etc/bf/ch.d/10-backup
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/backup postgres:postgres 0600 0700
3 changes: 0 additions & 3 deletions overlay/etc/bf/ch.d/10-postgresql

This file was deleted.

1 change: 1 addition & 0 deletions overlay/etc/bf/ch.d/11-data
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/data postgres:postgres 0600 0700
1 change: 1 addition & 0 deletions overlay/etc/bf/ch.d/12-run
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/run/postgresql postgres:postgres 0600 0700
2 changes: 1 addition & 1 deletion overlay/etc/nu/scripts/bf-postgresql/ctl.nu
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def cmd [
try {
^pg pg_ctl $command -D $"(bf env PG_DATA)"
} catch {
bf write error $"There was an error running pg_ctl ($command)."
bf write error $"There was an error running pg_ctl ($command)." ctl/cmd
}
}

Expand Down
9 changes: 5 additions & 4 deletions overlay/etc/nu/scripts/bf-postgresql/db.nu
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ export def dump [
file: string # The path to save the dump script to
] {
# ensure the database exists
if not (exists $name) { bf write error $"Database ($name) does not exist." export }
if not (exists $name) { bf write error $"Database ($name) does not exist." db/dump }

# dump database and save to specified file
{ ^pg pg_dump --clean --if-exists $name } | bf handle -s {|x| $x | save --force $file } ctl/dump
{ ^pg pg_dump --clean --if-exists $name } | bf handle -s {|x| $x | save --force $file } db/dump
}

# Get a list of databases, ignoring system databases
export def get_all [] {
# ignore these database
# ignore these databases
let ignore = [
"postgres"
"template0"
Expand All @@ -30,5 +30,6 @@ export def get_all [] {

# execute SQL and process response
let sql = "SELECT datname FROM pg_database;"
{ ^pg psql -c $sql | ^tail -n+3 | ^head -n-2 | ^xargs } | bf handle -d "Selecting PostgreSQL databases" ctl/get_all | split row " " | where {|x| $x not-in $ignore } | compact
let dmp = "Selecting PostgreSQL databases"
{ ^pg psql -c $sql | ^tail -n+3 | ^head -n-2 | ^xargs } | bf handle -d $dmp db/get_all | split row " " | where {|x| $x not-in $ignore } | compact
}
9 changes: 4 additions & 5 deletions overlay/etc/nu/scripts/bf-postgresql/dump.nu
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ use db.nu

# Backup the cluster to a dump file, compressing if required
export def main [] {
# set variables
bf write $"Dumping data cluster." dump

# create backup directories
bf write debug "Creating temporary directories." dump
let backup_dir = create_backup_dir
let temp_dir = bf fs make_temp_dir

# dump cluster and save to dump file
bf write $"Dumping data cluster." dump
let dump_file = $"($temp_dir)/(bf env PG_DUMP_BASENAME).sql"
bf write debug $" .. to ($dump_file)" dump
{ ^pg pg_dumpall --clean --if-exists } | bf handle -s {|x| $x | save --force $dump_file } dump
Expand Down Expand Up @@ -41,11 +40,11 @@ export def main [] {

# delete temporary directory
bf write debug $" .. deleting ($temp_dir)" dump
bf del force $temp_dir
bf del force $temp_dir

# cleanup old backup files
bf write debug " .. removing expired backup files" dump
bf del old --type d (bf env PG_BACKUP) (bf env PG_BACKUP_KEEP_FOR | into duration)
bf del old --live --type d (bf env PG_BACKUP) (bf env PG_BACKUP_KEEP_FOR | into duration)

# if we get here there have been no errors
bf write ok "Done." dump
Expand Down
9 changes: 5 additions & 4 deletions overlay/etc/nu/scripts/bf-postgresql/export.nu
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use bf
use db.nu

# Database $name will be exported as a sql file to the root backup directory
export def main [
name: string # The name of the database to export
] {
# Database will be exported as a sql file to the root backup directory
export def main [] {
# capture database name
let name = $in

# create path to export file
let export_file = $"(bf env PG_BACKUP)/($name).sql"

Expand Down
10 changes: 5 additions & 5 deletions overlay/etc/nu/scripts/bf-postgresql/import.nu
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use bf
use db.nu
use ctl.nu

# A file named $name.sql will be used from the root of the /backup directory
export def main [
name: string # The name of the database to import
] {
# Import database from the root of the /backup directory
export def main [] {
# capture database name
let name = $in

# ensure the file exists
let import_file = $"(bf env PG_BACKUP)/($name).sql"
if ($import_file | bf fs is_not_file) { bf write error $"Cannot find import file ($import_file)." import }
Expand Down
2 changes: 1 addition & 1 deletion overlay/etc/nu/scripts/bf-postgresql/restore.nu
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def check_dump_file [] {

# Restore cluster from a backup dump file
export def from [
backup: string # Restore the dump file this backup directory
backup: string # Restore the dump file from this backup directory
] {
# ensure requested backup directory exists
let backup_dir = $"(bf env PG_BACKUP)/($backup)"
Expand Down
2 changes: 1 addition & 1 deletion overlay/usr/bin/bf/pg-export
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ bf env load -x
def main [
name: string # The name of the database to export
] {
bf-postgresql export $name
$name | bf-postgresql export
}
2 changes: 1 addition & 1 deletion overlay/usr/bin/bf/pg-import
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ bf env load -x
def main [
name: string # The name of the database to import
] {
bf-postgresql import $name
$name | bf-postgresql import
}