about summary refs log tree commit diff
path: root/deploy
diff options
context:
space:
mode:
authorStarfall <root@starfall.blue>2019-12-29 19:23:27 -0600
committerStarfall <root@starfall.blue>2019-12-29 20:03:34 -0600
commit2cd0b58531236e367656853cabb80d666b60ed33 (patch)
treed96dca68ea74f077fcbf30a908dbccf42a67a457 /deploy
parent6a752d452a42d15f8af8f7a1bf66337dbc564541 (diff)
Add BACKUP_LOC option to backup script
Diffstat (limited to 'deploy')
-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