summaryrefslogtreecommitdiffstats
path: root/scripts/backup/postgres_backup_v2.sh
diff options
context:
space:
mode:
authorivarlovlie <git@ivarlovlie.no>2022-02-01 19:25:41 +0100
committerivarlovlie <git@ivarlovlie.no>2022-02-01 19:25:41 +0100
commit69a416caa2bce3dc4a3aff61fb8ae955f7561e51 (patch)
tree7f80e7f3143872c2e0a8867399abfcd35c9d5dbc /scripts/backup/postgres_backup_v2.sh
parentfdee7340ac18b0866abf0c44643f4c937fc4cf80 (diff)
downloaddotfiles-server-69a416caa2bce3dc4a3aff61fb8ae955f7561e51.tar.xz
dotfiles-server-69a416caa2bce3dc4a3aff61fb8ae955f7561e51.zip
Reorganise scripts
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