1
0
mirror of https://gitlab.crans.org/bde/nk20-scripts synced 2024-12-25 00:42:23 +00:00
nk20-scripts/shell/backup_db
2020-09-08 13:16:03 +02:00

10 lines
402 B
Bash
Executable File

#!/bin/bash
# Create temporary backups directory
[[ -d /tmp/note-backups ]] || mkdir /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
# 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"