From 1b64e6bce37b1e586803d62c2814abb242598b6a Mon Sep 17 00:00:00 2001 From: Michael LoPresti Date: Tue, 11 Aug 2020 21:02:59 -0400 Subject: [PATCH 1/3] updated mapper to use similar base to backup --- backup.Dockerfile | 12 ++++++++++++ backup.sh | 22 ++++++++++++++++++++++ docker-compose.yml | 13 +++++++++++++ mapper.Dockerfile | 4 ++-- mapper.sh | 2 +- 5 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 backup.Dockerfile create mode 100644 backup.sh 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..e5947d7 --- /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 -- {} +0 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 +5 0 * * * find /backup/daily | grep -v "/$" | tail -n +9 | xargs -I {} rm -- {} +0 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 +5 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..8d0d094 100644 --- a/mapper.sh +++ b/mapper.sh @@ -1,7 +1,7 @@ #!/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 From ed1103b256095a3323b66ba14af61960ee170d99 Mon Sep 17 00:00:00 2001 From: Michael LoPresti Date: Tue, 11 Aug 2020 21:10:12 -0400 Subject: [PATCH 2/3] Added backup documentation --- README.md | 11 ++++++++++- backup.sh | 8 ++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 91e3d6e..02de02f 100644 --- a/README.md +++ b/README.md @@ -6,4 +6,13 @@ 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~~ + +## 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.sh b/backup.sh index e5947d7..f403a10 100644 --- a/backup.sh +++ b/backup.sh @@ -10,10 +10,10 @@ 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 -- {} -0 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 -5 0 * * * find /backup/daily | grep -v "/$" | tail -n +9 | xargs -I {} rm -- {} -0 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 -5 0 * * 0 find /backup/weekly | grep -v "/$" | tail -n +10 | 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 From 24a56e5e7d3aae46b4bce5f133a30c3d5bf91da6 Mon Sep 17 00:00:00 2001 From: Michael LoPresti Date: Tue, 11 Aug 2020 21:14:47 -0400 Subject: [PATCH 3/3] Added mapper/web documentation --- README.md | 3 +++ mapper.sh | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 02de02f..fe6461c 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,9 @@ The goal of this project is to create a containerized minecraft app that does th 4. ~~Runs the [minecraft overviewer](https://github.com/overviewer/Minecraft-Overviewer) mapper~~ 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 diff --git a/mapper.sh b/mapper.sh index 8d0d094..23da2ad 100644 --- a/mapper.sh +++ b/mapper.sh @@ -4,7 +4,7 @@ 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