From 7e27c3b71b04af0867d5fbe4916e2d1278637599 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Tue, 8 Sep 2020 13:16:03 +0200 Subject: [PATCH] Backups are sent to Zamok --- shell/backup_db | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/shell/backup_db b/shell/backup_db index 435ef8e..f74939b 100755 --- a/shell/backup_db +++ b/shell/backup_db @@ -1,11 +1,9 @@ #!/bin/bash -# Create backups directory -[[ -d /var/www/note_kfet/backups ]] || (mkdir /var/www/note_kfet/backups && chown www-data:www-data /var/www/note_kfet/backups) +# 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 "/var/www/note_kfet/backups/$date.tar" > /dev/null +su postgres -c "pg_dump -F t note_db" | tee "/tmp/note-backups/$date.tar" > /dev/null # Compress backup as gzip -gzip "/var/www/note_kfet/backups/$date.tar" -chown www-data:www-data "/var/www/note_kfet/backups/$date.tar.gz" -# Delete backups that have more than 30 days -find /var/www/note_kfet/backups -type f -mtime +30 -exec rm {} \; \ No newline at end of file +gzip "/tmp/note-backups/$date.tar" +scp "/tmp/note-backups/$date.tar.gz" "club-bde@zamok.crans.org:backup/$date.tar.gz"