summaryrefslogtreecommitdiffstats
path: root/scripts/backup/postgres_backup_v2.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/backup/postgres_backup_v2.sh')
-rwxr-xr-xscripts/backup/postgres_backup_v2.sh16
1 files changed, 16 insertions, 0 deletions
diff --git a/scripts/backup/postgres_backup_v2.sh b/scripts/backup/postgres_backup_v2.sh
new file mode 100755
index 0000000..1f06514
--- /dev/null
+++ b/scripts/backup/postgres_backup_v2.sh
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+set -Eeuo pipefail
+
+backup_folder="/opt/backup/db/$(date -u +%F)"
+postgres_host="127.0.0.1"
+postgres_port="5432"
+filename="$(date -u +%H%M%S).psqldump"
+
+[ ! -d $backup_folder ] && mkdir -p $backup_folder
+
+pushd $backup_folder
+
+pg_dumpall --host=$postgres_host --port=$postgres_port -U postgres --clean --if-exists -f $filename
+
+popd