2020-08-06 07:26:16 +00:00
|
|
|
#!/bin/bash
|
2020-09-08 11:16:03 +00:00
|
|
|
# Create temporary backups directory
|
|
|
|
[[ -d /tmp/note-backups ]] || mkdir /tmp/note-backups
|
2020-08-06 07:26:16 +00:00
|
|
|
date=$(date +%Y-%m-%d)
|
|
|
|
# Backup database and save it as tar archive
|
2020-09-08 11:16:03 +00:00
|
|
|
su postgres -c "pg_dump -F t note_db" | tee "/tmp/note-backups/$date.tar" > /dev/null
|
2020-08-06 07:26:16 +00:00
|
|
|
# Compress backup as gzip
|
2020-09-08 11:16:03 +00:00
|
|
|
gzip "/tmp/note-backups/$date.tar"
|
|
|
|
scp "/tmp/note-backups/$date.tar.gz" "club-bde@zamok.crans.org:backup/$date.tar.gz"
|