summaryrefslogtreecommitdiffstats
path: root/postgresql/bin/postgresql-backup
diff options
context:
space:
mode:
Diffstat (limited to 'postgresql/bin/postgresql-backup')
-rwxr-xr-xpostgresql/bin/postgresql-backup23
1 files changed, 22 insertions, 1 deletions
diff --git a/postgresql/bin/postgresql-backup b/postgresql/bin/postgresql-backup
index ca2df8d..beaf2d8 100755
--- a/postgresql/bin/postgresql-backup
+++ b/postgresql/bin/postgresql-backup
@@ -2,7 +2,7 @@
# Open Infrastructure: service-tools
-# Copyright (C) 2014-2021 Daniel Baumann <daniel.baumann@open-infrastructure.net>
+# Copyright (C) 2014-2022 Daniel Baumann <daniel.baumann@open-infrastructure.net>
#
# SPDX-License-Identifier: GPL-3.0+
#
@@ -21,6 +21,27 @@
set -e
+
+#!/bin/sh
+
+set -e
+
+DIRECTORY="/srv/$(cat /etc/hostname)/postgresql-backup/$(date +%Y-%m-%d)"
+DATABASES="fbm_test"
+
+mkdir -p "${DIRECTORY}"
+chown -R postgres:postgres "${DIRECTORY}"
+
+for DATABASE in ${DATABASES}
+do
+ su - postgres -c "pg_dump -f ${DIRECTORY} -F d -j $(nproc) -C -d ${DATABASE}"
+done
+
+chown -R root:root "${DIRECTORY}"
+
+
+
+
# FIXME
#postgres pg_dump ${DATABASE} | plzip > postgresql-backup/${DATABASE}-"$(date +\%Y\%m\%d)".sql.lz
#find postgresql-backup/ -mtime +90 -name "${DATABASE}-*lz" | xargs -r rm