Add cron container for daily backups and content export
- Add cron service to docker-compose with backup (3 AM) and export (4 AM) schedules - Remove redundant content/articles/ and content/curriculum/ (now in Outline, exported to content/wiki/) - Fix env var mismatch: support both OUTLINE_API_KEY and OUTLINE_API_TOKEN - Drop updatedAt from export frontmatter to reduce noisy commits - Add backups/ to gitignore
This commit is contained in:
parent
f5a69b8683
commit
8e7424ed05
49 changed files with 84 additions and 7530 deletions
19
cron/Dockerfile
Normal file
19
cron/Dockerfile
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
FROM alpine:3.20
|
||||
|
||||
RUN apk add --no-cache \
|
||||
bash \
|
||||
docker-cli \
|
||||
git \
|
||||
nodejs \
|
||||
npm \
|
||||
openssh-client \
|
||||
gzip
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY crontab /etc/crontabs/root
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
CMD ["crond", "-f", "-l", "2"]
|
||||
6
cron/crontab
Normal file
6
cron/crontab
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
# Outline database + file backup — daily at 3 AM UTC
|
||||
0 3 * * * /app/scripts/outline-backup.sh /backups/outline >> /var/log/outline-backup.log 2>&1
|
||||
|
||||
# Wiki content export to git — daily at 4 AM UTC
|
||||
0 4 * * * /app/scripts/export-content-cron.sh >> /var/log/wiki-export.log 2>&1
|
||||
|
||||
25
cron/entrypoint.sh
Normal file
25
cron/entrypoint.sh
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Install node dependencies for export script
|
||||
cd /app
|
||||
if [ -f scripts/package.json ]; then
|
||||
cd scripts && npm install --production && cd ..
|
||||
fi
|
||||
|
||||
# Configure git for automated commits
|
||||
git config --global --add safe.directory /app
|
||||
git config --global user.email "wiki-bot@ghostguild.org"
|
||||
git config --global user.name "Wiki Bot"
|
||||
|
||||
# Add git remote host to known_hosts so SSH doesn't prompt
|
||||
mkdir -p /root/.ssh_tmp
|
||||
cp /root/.ssh/* /root/.ssh_tmp/ 2>/dev/null || true
|
||||
ssh-keyscan -t ed25519,rsa git.ghostguild.org >> /root/.ssh_tmp/known_hosts 2>/dev/null
|
||||
export GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/root/.ssh_tmp/known_hosts -i /root/.ssh/id_ed25519"
|
||||
|
||||
echo "Cron jobs loaded:"
|
||||
crontab -l
|
||||
echo "Starting crond..."
|
||||
|
||||
exec "$@"
|
||||
Loading…
Add table
Add a link
Reference in a new issue