Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,16 @@ The goal of this project is to create a containerized minecraft app that does th
2. Runs the [equivalent exchange mod](https://github.com/sinkillerj/ProjectE)
3. Compile forge in base image
4. ~~Runs the [minecraft overviewer](https://github.com/overviewer/Minecraft-Overviewer) mapper~~
5. Automagic backup the backup
5. ~~Automagic backup the backup~~

## Map/Web
The mapper service runs a cron that runs [minecraft overviewer](https://github.com/overviewer/Minecraft-Overviewer) every 10 minutes. The files from that process are saved to a voume that is shared to the web service. That service runs nginx and makes the map available on port 80

## Backup
Backups are handled by a cron in the backups service. Backups follow the following schedule.
#### Hourly
Hourly backups run at the top of each hour. 24 hourly backups are retained.
#### Daily
Daily backups are ran at 00:05:00 each day. 7 daily backups are retained.
#### Weekly
Weekly backups are ran sundays at 00:10:00. 8 weekly backups are retained.
12 changes: 12 additions & 0 deletions backup.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM ubuntu:18.04

RUN apt-get update -y

ARG MINECRAFT_VERSION

RUN apt-get update -y && \
apt-get install \
cron -y

COPY backup.sh /entrypoint.sh
ENTRYPOINT /entrypoint.sh
22 changes: 22 additions & 0 deletions backup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

# Start the run once job.
echo "backup container has been started"

mkdir /backup/hourly
mkdir /backup/daily
mkdir /backup/weekly

# Setup a cron schedule
echo '0 * * * * datetime=$(date +"%Y%m%d%H%M%S") && echo "created /backup/hourly/$datetime.tar.gz" >> /var/log/cron.log 2>&1 && tar -czvf "/backup/hourly/$datetime.tar.gz" /world >> /var/log/cron.log 2>&1
5 * * * * find /backup/hourly | grep -v "/$" | tail -n +26 | xargs -I {} rm -- {}
5 0 * * * datetime=$(date +"%Y%m%d%H%M%S") && echo "created /backup/daily/$datetime.tar.gz" >> /var/log/cron.log 2>&1 && tar -czvf "/backup/daily/$datetime.tar.gz" /world >> /var/log/cron.log 2>&1
10 0 * * * find /backup/daily | grep -v "/$" | tail -n +9 | xargs -I {} rm -- {}
10 0 * * 0 datetime=$(date +"%Y%m%d%H%M%S") && echo "created /backup/weekly/$datetime.tar.gz" >> /var/log/cron.log 2>&1 && tar -czvf "/backup/weekly/$datetime.tar.gz" /world >> /var/log/cron.log 2>&1
15 0 * * 0 find /backup/weekly | grep -v "/$" | tail -n +10 | xargs -I {} rm -- {}
# This extra line makes it a valid cron' > scheduler.txt

crontab scheduler.txt
cron
touch /var/log/cron.log
tail -f /var/log/cron.log
13 changes: 13 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,18 @@ services:
target: /usr/share/nginx/html
read_only: true

backup:
build:
dockerfile: backup.Dockerfile
context: .
volumes:
- type: bind
source: C:\temp\world
target: /world
read_only: true
- type: bind
source: c:\temp\backup
target: /backup

volumes:
mapper_output: {}
4 changes: 2 additions & 2 deletions mapper.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Base Image
FROM ubuntu:18.04

RUN apt-get update -y

ARG MINECRAFT_VERSION
ARG OVERVIEWER_VERSION

RUN apt-get update -y

# Add build dependency
RUN apt-get update -y && \
apt-get install \
Expand Down
4 changes: 2 additions & 2 deletions mapper.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/bash

# Start the run once job.
echo "Docker container has been started"
echo "mapper container has been started"

# Setup a cron schedule
echo "*/5 * * * * /usr/local/src/Minecraft-Overviewer/overviewer.py /world /output >> /var/log/cron.log 2>&1
echo "*/10 * * * * /usr/local/src/Minecraft-Overviewer/overviewer.py /world /output >> /var/log/cron.log 2>&1
# This extra line makes it a valid cron" > scheduler.txt

crontab scheduler.txt
Expand Down