feat: use cron to run backups
This commit is contained in:
parent
d2a3aa0b32
commit
6dc493b37e
3 changed files with 25 additions and 7 deletions
|
@ -1,5 +1,12 @@
|
||||||
FROM kopia/kopia
|
FROM kopia/kopia
|
||||||
|
|
||||||
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
RUN apt-get update && apt-get install -y cron && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
ARG KOPIA_CRON_TIMES="*/30 * * * *"
|
||||||
|
ENV KOPIA_CRON_TIMES ${KOPIA_CRON_TIMES}
|
||||||
|
|
||||||
|
ADD run-backup.sh /
|
||||||
ADD entrypoint.sh /
|
ADD entrypoint.sh /
|
||||||
|
|
||||||
ENTRYPOINT [ "/entrypoint.sh" ]
|
ENTRYPOINT [ "/entrypoint.sh" ]
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
kopia --version
|
CRONTAB=/etc/cron.d/kopia-backup
|
||||||
|
|
||||||
kopia repository connect filesystem \
|
echo "Running cron with schedule ${KOPIA_CRON_TIMES}"
|
||||||
--path /repository \
|
|
||||||
--override-hostname ${KOPIA_HOSTNAME} \
|
|
||||||
--override-username ${KOPIA_USERNAME}
|
|
||||||
|
|
||||||
sleep infinity
|
echo "${KOPIA_CRON_TIMES} /run-backup.sh > /dev/stdout" > ${CRONTAB}
|
||||||
|
chmod 0644 ${CRONTAB}
|
||||||
|
crontab ${CRONTAB}
|
||||||
|
|
||||||
|
cron -f
|
||||||
|
|
10
run-backup.sh
Executable file
10
run-backup.sh
Executable file
|
@ -0,0 +1,10 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
kopia --version
|
||||||
|
|
||||||
|
kopia repository connect filesystem \
|
||||||
|
--path /repository \
|
||||||
|
--override-hostname ${KOPIA_HOSTNAME} \
|
||||||
|
--override-username ${KOPIA_USERNAME}
|
||||||
|
|
||||||
|
kopia snapshot create /backup
|
Loading…
Reference in a new issue