diff --git a/README.md b/README.md index 91e3d6e..fe6461c 100644 --- a/README.md +++ b/README.md @@ -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 \ No newline at end of file +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. \ No newline at end of file diff --git a/backup.Dockerfile b/backup.Dockerfile new file mode 100644 index 0000000..ec2fba8 --- /dev/null +++ b/backup.Dockerfile @@ -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 \ No newline at end of file diff --git a/backup.sh b/backup.sh new file mode 100644 index 0000000..f403a10 --- /dev/null +++ b/backup.sh @@ -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 \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index b1a4492..4ccf1a7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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: {} diff --git a/mapper.Dockerfile b/mapper.Dockerfile index 9738730..c3cea44 100644 --- a/mapper.Dockerfile +++ b/mapper.Dockerfile @@ -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 \ diff --git a/mapper.sh b/mapper.sh index f68f122..23da2ad 100644 --- a/mapper.sh +++ b/mapper.sh @@ -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