Skip to content

Commit

Permalink
Upgraded server scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
kristoferlund committed Jul 28, 2022
1 parent 23fdb3a commit fddcdfd
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 1 deletion.
3 changes: 3 additions & 0 deletions database-backup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
export $(grep -v '^#' .env | xargs)
docker exec -i mongodb-praise /usr/bin/mongodump --authenticationDatabase admin --archive -u $MONGO_INITDB_ROOT_USERNAME -p $MONGO_INITDB_ROOT_PASSWORD --db praise_db > database-backup-$(date +"%F-%T").archive
11 changes: 11 additions & 0 deletions database-restore.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
if ! test -f "$1" ; then
echo "Could not find database backup"
echo "Usage: database-restore.sh filename\n"
fi
export $(grep -v '^#' .env | xargs)
docker compose -f ./docker-compose.production.yml down
docker volume rm $(docker volume ls -q)
docker compose -f ./docker-compose.production.yml up mongodb -d --remove-orphans
docker exec -i mongodb-praise sh -c 'mongorestore --authenticationDatabase admin -u $MONGO_INITDB_ROOT_USERNAME -p $MONGO_INITDB_ROOT_PASSWORD --nsInclude=praise_db.* --archive' < $1
docker compose -f ./docker-compose.production.yml up -d --remove-orphans
20 changes: 20 additions & 0 deletions reset.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
echo
echo "⚠ Running this script will delete ALL Praise data!"
read -p "Are you sure? (N/y) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
echo
echo "Shutting down containers..."
echo
docker compose -f ./docker-compose.production.yml down
echo
echo "Deleting images..."
echo
docker rmi -f $(docker images -aq)
echo
echo "Deleting volumes..."
echo
docker volume rm $(docker volume ls -q)
fi
3 changes: 3 additions & 0 deletions restart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
docker compose -f ./docker-compose.production.yml down
docker compose -f ./docker-compose.production.yml up
9 changes: 8 additions & 1 deletion setup.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
docker build -t praise-setup -f ./packages/setup/Dockerfile .
#!/bin/bash
IMAGE=$( docker images | grep praise-setup )
if [ -z "$IMAGE" ]
then
echo "Building setup image..."
docker build -t praise-setup -q -f ./packages/setup/Dockerfile .
fi

docker run -it -v $(pwd):/usr/praise praise-setup
1 change: 1 addition & 0 deletions start.sh
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#!/bin/bash
docker compose -f ./docker-compose.production.yml up -d
1 change: 1 addition & 0 deletions upgrade.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash
docker compose -f ./docker-compose.production.yml pull
docker compose -f ./docker-compose.production.yml down
docker compose -f ./docker-compose.production.yml up -d --remove-orphans

0 comments on commit fddcdfd

Please sign in to comment.