File tree 3 files changed +32
-4
lines changed
overlay/usr/lib/bf/postgresql 3 files changed +32
-4
lines changed Original file line number Diff line number Diff line change 1
- 14.0-r3
1
+ 14.0-r5
Original file line number Diff line number Diff line change 1
- 1.0.2
1
+ 1.0.3
Original file line number Diff line number Diff line change @@ -26,15 +26,43 @@ bf-echo "Backing up server to ${TEMP_BACKUP_PATH}..."
26
26
27
27
# dump cluster
28
28
DUMP_FILE="${TEMP_BACKUP_PATH}/${POSTGRESQL_BACKUP_FILENAME}.sql"
29
- bf-debug " .. dumping cluster to ${DUMP_FILE} "
29
+ bf-debug " .. dumping cluster"
30
30
pg_dumpall > "${DUMP_FILE}"
31
31
32
32
# compress file
33
33
if [ "${POSTGRESQL_BACKUP_COMPRESS_FILES}" = "1" ] ; then
34
- bf-debug " .. compressing cluster backup "
34
+ bf-debug " .. compressing"
35
35
gzip ${DUMP_FILE}
36
36
fi
37
37
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
+
38
66
bf-done
39
67
40
68
You can’t perform that action at this time.
0 commit comments