Skip to content

Commit

Permalink
Scripts to backup and restore database
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexMacocian committed Aug 9, 2024
1 parent f35d5fd commit 19eefc4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion .github/workflows/docker-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,20 @@ jobs:
sshpass -p "${{ secrets.HOST_PASS }}" scp -o StrictHostKeyChecking=no guildwarspartysearch.server.tar ${{ secrets.HOST_USER }}@${{ secrets.HOST_ADDRESS }}:/home/guildwarspartysearch/staging
echo "Uploading configuration"
sshpass -p "${{ secrets.HOST_PASS }}" scp -o StrictHostKeyChecking=no Config.json ${{ secrets.HOST_USER }}@${{ secrets.HOST_ADDRESS }}:/home/guildwarspartysearch/staging
echo "Stopping running contianer"
sshpass -p "${{ secrets.HOST_PASS }}" ssh -o StrictHostKeyChecking=no ${{ secrets.HOST_USER }}@${{ secrets.HOST_ADDRESS }} "docker stop partysearch"
echo "Backing up database"
sshpass -p "${{ secrets.HOST_PASS }}" ssh -o StrictHostKeyChecking=no ${{ secrets.HOST_USER }}@${{ secrets.HOST_ADDRESS }} "docker cp partysearch:/app/partysearches.db /home/guildwarspartysearch/staging/partysearches.db"
echo "Stopping and removing old containers"
sshpass -p "${{ secrets.HOST_PASS }}" ssh -o StrictHostKeyChecking=no ${{ secrets.HOST_USER }}@${{ secrets.HOST_ADDRESS }} "docker rmi -f guildwarspartysearch.server:latest"
sshpass -p "${{ secrets.HOST_PASS }}" ssh -o StrictHostKeyChecking=no ${{ secrets.HOST_USER }}@${{ secrets.HOST_ADDRESS }} "docker rm partysearch && docker rmi -f guildwarspartysearch.server:latest"
echo "Loading new image"
sshpass -p "${{ secrets.HOST_PASS }}" ssh -o StrictHostKeyChecking=no ${{ secrets.HOST_USER }}@${{ secrets.HOST_ADDRESS }} "docker load -i /home/guildwarspartysearch/staging/guildwarspartysearch.server.tar"
echo "Creating container"
sshpass -p "${{ secrets.HOST_PASS }}" ssh -o StrictHostKeyChecking=no ${{ secrets.HOST_USER }}@${{ secrets.HOST_ADDRESS }} "docker create --name partysearch -p 8080:80 guildwarspartysearch.server:latest"
echo "Copying configuration into container"
sshpass -p "${{ secrets.HOST_PASS }}" ssh -o StrictHostKeyChecking=no ${{ secrets.HOST_USER }}@${{ secrets.HOST_ADDRESS }} "docker cp /home/guildwarspartysearch/staging/Config.json partysearch:/app/Config.json"
echo "Copying database backup into container"
sshpass -p "${{ secrets.HOST_PASS }}" ssh -o StrictHostKeyChecking=no ${{ secrets.HOST_USER }}@${{ secrets.HOST_ADDRESS }} "docker cp /home/guildwarspartysearch/staging/partysearches.db partysearch:/app/partysearches.db"
echo "Starting container"
sshpass -p "${{ secrets.HOST_PASS }}" ssh -o StrictHostKeyChecking=no ${{ secrets.HOST_USER }}@${{ secrets.HOST_ADDRESS }} "docker start partysearch"
echo "Cleaning up"
Expand Down

0 comments on commit 19eefc4

Please sign in to comment.