From 354a1f845ecc06a9fce343c5180f21f89d12f730 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Thu, 31 Aug 2023 12:21:48 +0200 Subject: [PATCH] Update backup script Remove useless tee, use "mkdir -p" and use .sql.gz. --- shell/backup_db | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/shell/backup_db b/shell/backup_db index f74939b..2160106 100755 --- a/shell/backup_db +++ b/shell/backup_db @@ -1,9 +1,9 @@ #!/bin/bash # Create temporary backups directory -[[ -d /tmp/note-backups ]] || mkdir /tmp/note-backups +mkdir -p /tmp/note-backups date=$(date +%Y-%m-%d) # Backup database and save it as tar archive -su postgres -c "pg_dump -F t note_db" | tee "/tmp/note-backups/$date.tar" > /dev/null +sudo -u postgres pg_dump -F t note_db > "/tmp/note-backups/$date.sql" # Compress backup as gzip -gzip "/tmp/note-backups/$date.tar" -scp "/tmp/note-backups/$date.tar.gz" "club-bde@zamok.crans.org:backup/$date.tar.gz" +gzip "/tmp/note-backups/$date.sql" +scp "/tmp/note-backups/$date.sql.gz" "club-bde@zamok.crans.org:backup/$date.sql.gz"