Skip to content

Commit e337756

Browse files
authored
v1.0.3 (#4)
Major updates * Using latest 14.0 build * Adding individual database backups
1 parent 1c86d14 commit e337756

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

14/POSTGRESQL_BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
14.0-r3
1+
14.0-r5

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.2
1+
1.0.3

overlay/usr/lib/bf/postgresql/backup

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,43 @@ bf-echo "Backing up server to ${TEMP_BACKUP_PATH}..."
2626

2727
# dump cluster
2828
DUMP_FILE="${TEMP_BACKUP_PATH}/${POSTGRESQL_BACKUP_FILENAME}.sql"
29-
bf-debug " .. dumping cluster to ${DUMP_FILE}"
29+
bf-debug " .. dumping cluster"
3030
pg_dumpall > "${DUMP_FILE}"
3131

3232
# compress file
3333
if [ "${POSTGRESQL_BACKUP_COMPRESS_FILES}" = "1" ] ; then
34-
bf-debug " .. compressing cluster backup"
34+
bf-debug " .. compressing"
3535
gzip ${DUMP_FILE}
3636
fi
3737

38+
39+
#======================================================================================================================
40+
# Get list of individual databases, dump and compress.
41+
#======================================================================================================================
42+
43+
# remove header / footer from output
44+
EXCLUDE="postgres|template0|template1"
45+
bf-debug " .. excluding ${EXCLUDE} from individual backups"
46+
DATABASES=$(psql -c "SELECT datname FROM pg_database;" | tail -n+3 | head -n-2 | grep -v -E "(${EXCLUDE})")
47+
48+
# dump each database
49+
for DATABASE in ${DATABASES} ; do
50+
51+
# path to this database dump
52+
DUMP_FILE="${TEMP_BACKUP_PATH}/${DATABASE}.sql"
53+
54+
# dump database and continue on failure
55+
bf-debug " .. dumping database ${DATABASE}"
56+
pg_dump ${DATABASE} > ${DUMP_FILE}|| true
57+
58+
# compress file
59+
if [ "${POSTGRESQL_BACKUP_COMPRESS_FILES}" = "1" ] ; then
60+
bf-debug " .. compressing"
61+
gzip ${DUMP_FILE}
62+
fi
63+
64+
done
65+
3866
bf-done
3967

4068

0 commit comments

Comments
 (0)