about summary refs log tree commit diff
path: root/deploy/scripts
diff options
context:
space:
mode:
authorreverite <samantha@chalker.io>2018-03-27 22:05:35 -0700
committerreverite <samantha@chalker.io>2018-03-27 22:05:35 -0700
commit8550be23e6dd30ab24b109185ead7ae432903cce (patch)
tree944ec2ecd9e35c649d3fcc6827db2582a54e698e /deploy/scripts
parent0e335fdbe68e827cbe23ea376c9efe28dc91aaef (diff)
rearrange
Diffstat (limited to 'deploy/scripts')
-rwxr-xr-xdeploy/scripts/backup.sh18
-rwxr-xr-xdeploy/scripts/update-containers.sh12
2 files changed, 30 insertions, 0 deletions
diff --git a/deploy/scripts/backup.sh b/deploy/scripts/backup.sh
new file mode 100755
index 0000000..b9a4b06
--- /dev/null
+++ b/deploy/scripts/backup.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+[ -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
+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"
+fi
diff --git a/deploy/scripts/update-containers.sh b/deploy/scripts/update-containers.sh
new file mode 100755
index 0000000..ff63e9e
--- /dev/null
+++ b/deploy/scripts/update-containers.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+[ -z "$COMPOSE" ] && COMPOSE="$(command -v docker-compose)"
+[ -z "$COMPOSE" ] && COMPOSE="/usr/local/bin/docker-compose"
+
+cd $HOME
+
+($COMPOSE pull 2>&1 | grep --silent "Downloaded newer") && \
+  $COMPOSE up -d && \
+  docker cp $($COMPOSE ps -q mstweb):/mastodon/public/assets public/ && \
+  docker cp $($COMPOSE ps -q mstweb):/mastodon/public/packs public/ && \
+  docker image prune -f