From e807ba634765c1683f3516cc4b4ba232d4b491d6 Mon Sep 17 00:00:00 2001 From: faulty Date: Sun, 12 Feb 2023 22:51:46 +0100 Subject: [PATCH] add: backups --- .gitmodules | 3 ++ custom/backups/Dockerfile | 39 +++++++++++++++++++++++ custom/backups/config/global.json | 4 +++ custom/backups/config/tasks/server.json | 11 +++++++ custom/backups/config/tasks/services.json | 16 ++++++++++ repos/backups => custom/backups/repo | 0 6 files changed, 73 insertions(+) create mode 100755 custom/backups/Dockerfile create mode 100755 custom/backups/config/global.json create mode 100644 custom/backups/config/tasks/server.json create mode 100755 custom/backups/config/tasks/services.json rename repos/backups => custom/backups/repo (100%) diff --git a/.gitmodules b/.gitmodules index 0515583..9fd7d96 100644 --- a/.gitmodules +++ b/.gitmodules @@ -15,3 +15,6 @@ [submodule "repos/ixvd-site"] path = repos/ixvd-site url = git@git.ixvd.net:this/site +[submodule "custom/backups/repo"] + path = custom/backups/repo + url = git@git.ixvd.net:infra/backups diff --git a/custom/backups/Dockerfile b/custom/backups/Dockerfile new file mode 100755 index 0000000..61d1905 --- /dev/null +++ b/custom/backups/Dockerfile @@ -0,0 +1,39 @@ +FROM alpine:latest + +MAINTAINER Didier +LABEL Description="Faulty's (totally original) backup app" + +# Add a non root user +RUN adduser -s /bin/sh -D backups +RUN addgroup containers +RUN addgroup backups containers + +# python +RUN apk add --update --no-cache python3 && ln -sf python3 /usr/bin/python + +# directories +RUN mkdir /app +RUN mkdir /config +RUN mkdir /data +RUN mkdir /remote +RUN mkdir /local + +# chown +RUN chown -R backups:containers /app +RUN chown -R backups:containers /config +RUN chown -R backups:containers /data +RUN chown -R backups:containers /local +RUN chown -R backups:containers /remote + +# copy files +COPY ./repo/src/main.py /app/main.py +COPY ./repo/src/lib /app/lib +COPY ./repo/src/sample_configs /app/default_config + +# copy config +COPY ./config /config + +USER backups +WORKDIR /app +ENV PYTHONUNBUFFERED=true +ENTRYPOINT python3 main.py \ No newline at end of file diff --git a/custom/backups/config/global.json b/custom/backups/config/global.json new file mode 100755 index 0000000..c0054a2 --- /dev/null +++ b/custom/backups/config/global.json @@ -0,0 +1,4 @@ +{ + "remote_dir": "/remote", + "tasks_dir": "/config/tasks" +} \ No newline at end of file diff --git a/custom/backups/config/tasks/server.json b/custom/backups/config/tasks/server.json new file mode 100644 index 0000000..7fcaee9 --- /dev/null +++ b/custom/backups/config/tasks/server.json @@ -0,0 +1,11 @@ +{ + "name": "serverBuildTools", + "interval": 604800, + "base": "/data", + "paths": [ + "docker" + ], + "local_days_of_retention": 1, + "remote_days_of_retention": 30, + "backup_dir": "/local" +} \ No newline at end of file diff --git a/custom/backups/config/tasks/services.json b/custom/backups/config/tasks/services.json new file mode 100755 index 0000000..ce69944 --- /dev/null +++ b/custom/backups/config/tasks/services.json @@ -0,0 +1,16 @@ +{ + "name": "commonServicesData", + "interval": 172800, + "base": "/data/services", + "paths": [ + "cryptpad", + "gitlab", + "dendrite", + "smpxmc", + "kasmc", + "smpxterraria" + ], + "local_days_of_retention": 2, + "remote_days_of_retention": 30, + "backup_dir": "/local" +} \ No newline at end of file diff --git a/repos/backups b/custom/backups/repo similarity index 100% rename from repos/backups rename to custom/backups/repo