about summary refs log tree commit diff
path: root/deploy/scripts/backup.sh
diff options
context:
space:
mode:
Diffstat (limited to 'deploy/scripts/backup.sh')
-rwxr-xr-xdeploy/scripts/backup.sh14
1 files changed, 9 insertions, 5 deletions
diff --git a/deploy/scripts/backup.sh b/deploy/scripts/backup.sh
index b9a4b06..ae2c774 100755
--- a/deploy/scripts/backup.sh
+++ b/deploy/scripts/backup.sh
@@ -1,18 +1,22 @@
 #!/bin/bash
 
+[ -z "$BACKUP_LOC" ] && BACKUP_LOC="$HOME/backups"
+[ ! -e "$BACKUP_LOC" ] && mkdir -p $BACKUP_LOC
+
 [ -z "$COMPOSE" ] && COMPOSE="$(command -v docker-compose)"
 [ -z "$COMPOSE" ] && COMPOSE="/usr/local/bin/docker-compose"
+
 [ -z "$YML_LOC" ] && YML_LOC="$HOME/docker-compose.yml"
 
 COMPOSE="$COMPOSE -f $YML_LOC"
 
 if [ "$1" == 'daily' ]; then
-  find $HOME/backups -type f -name postgres-daily.* -mtime +7 -delete
-  $COMPOSE exec -T -u postgres mstdb sh -c "umask 0377 && /usr/local/bin/pg_dump -Fc -h mstdb -d postgres -U postgres" > "$HOME/backups/postgres-daily.$(date -Iseconds).pgsql"
-  $COMPOSE run -T --rm web rake mastodon:media:remove_remote
+	find $BACKUP_LOC -type f -name postgres-daily.* -mtime +7 -delete
+	$COMPOSE exec -T -u postgres db sh -c "umask 0377 && /usr/local/bin/pg_dump -Fc -h db -d postgres -U postgres" > "$BACKUP_LOC/postgres-daily.$(date -Iseconds).pgsql"
+	$COMPOSE run -T --rm rails rake mastodon:media:remove_remote
 fi
 
 if [ "$1" == 'hourly' ]; then
-  find $HOME/backups -type f -name postgres-hourly.* -mmin +360 -delete
-  $COMPOSE exec -T -u postgres mstdb sh -c "umask 0377 && /usr/local/bin/pg_dump -Fc -h mstdb -d postgres -U postgres" > "$HOME/backups/postgres-hourly.$(date -Iseconds).pgsql"
+	find $BACKUP_LOC -type f -name postgres-hourly.* -mmin +360 -delete
+	$COMPOSE exec -T -u postgres db sh -c "umask 0377 && /usr/local/bin/pg_dump -Fc -h db -d postgres -U postgres" > "$BACKUP_LOC/postgres-hourly.$(date -Iseconds).pgsql"
 fi