forked from mastodon/mastodon
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix docker-compose.yml and add backup.sh
- Loading branch information
Showing
5 changed files
with
128 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,9 @@ | |
/redis | ||
/elasticsearch | ||
|
||
# Ignore posgres backup | ||
/postgres_backups | ||
|
||
# Ignore Apple files | ||
.DS_Store | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +0,0 @@ | ||
[submodule "BlueGreenCompose"] | ||
path = BlueGreenCompose | ||
url = git@github.com:fono09/BlueGreenCompose.git | ||
Submodule BlueGreenCompose
deleted from
fc730e
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/bash | ||
set -euxo pipefail | ||
|
||
cd `dirname $0` | ||
pwd | ||
|
||
BACKUP_DIR=postgres_backups | ||
BACKUP_LIMIT=5 | ||
BACKUP_COUNT=`ls $BACKUP_DIR | wc -l` | ||
SERVICE_NAME=mastodon_db_backup | ||
|
||
get_service_state(){ | ||
echo `docker service ps --format '{{ .DesiredState }}' $1` | ||
} | ||
|
||
if [[ `get_service_state $SERVICE_NAME` != "Running" ]]; then | ||
docker service scale mastodon_db_backup=1 | ||
fi | ||
|
||
while [[ `get_service_state $SERVICE_NAME` == "Running" ]]; do | ||
sleep 10 | ||
done | ||
|
||
docker service scale mastodon_db_backup=0 | ||
|
||
if [[ $BACKUP_COUNT -lt $BACKUP_LIMIT ]]; then | ||
exit 0 | ||
fi | ||
|
||
DELETE_COUNT=$((BACKUP_COUNT - BACKUP_LIMIT)) | ||
|
||
cd $BACKUP_DIR | ||
ls | sort -n | head -$DELETE_COUNT | xargs rm -r |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters