1
0
mirror of https://gitlab.crans.org/bde/nk20-scripts synced 2024-12-24 16:32:22 +00:00

Update backup script

Remove useless tee, use "mkdir -p" and use .sql.gz.
This commit is contained in:
Alexandre Iooss 2023-08-31 12:21:48 +02:00 committed by charliep
parent f580f9b9e9
commit 354a1f845e

View File

@ -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"