From b8b2d30f75373629b0a917b274ac417f662a0e09 Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Tue, 5 Nov 2024 10:45:30 +0100 Subject: [PATCH 1/3] crontab should include daily/monthly/... run-parts --- cloud-init.yaml | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/cloud-init.yaml b/cloud-init.yaml index 7e0ea38..058991f 100644 --- a/cloud-init.yaml +++ b/cloud-init.yaml @@ -151,11 +151,29 @@ write_files: @include "/etc/syslog-ng/conf.d/*.conf" path: /etc/syslog-ng/syslog-ng.conf - content: | - # /etc/crontab: configuration file for cron + # /etc/crontab: system-wide crontab + # Unlike any other crontab you don't have to run the `crontab' + # command to install the new version when you edit this file + # and files in /etc/cron.d. These files also have username fields, + # that none of the other crontabs do. - # See cron(8) and crontab(5) for details. + SHELL=/bin/sh + # You can also override PATH, but by default, newer versions inherit it from the environment + #PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin + + # Example of job definition: + # .---------------- minute (0 - 59) + # | .------------- hour (0 - 23) + # | | .---------- day of month (1 - 31) + # | | | .------- month (1 - 12) OR jan,feb,mar,apr ... + # | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat + # | | | | | + # * * * * * user-name command to be executed + 17 * * * * root cd / && run-parts --report /etc/cron.hourly + 25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ) + 47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly ) + 52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly ) - # m h dom mon dow user command 23 12 * * * root /root/launch_container_demo.sh && sleep 1 && /root/demo_initialize_data.sh 23 0 * * * root /root/launch_container_demo.sh && sleep 1 && /root/demo_initialize_data.sh path: /etc/crontab From 4f263b2e61968a7e7eea3f9af6a69985627763ea Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Fri, 8 Nov 2024 08:12:20 +0100 Subject: [PATCH 2/3] Add a volume to happydomain container --- cloud-init.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloud-init.yaml b/cloud-init.yaml index 058991f..8b77879 100644 --- a/cloud-init.yaml +++ b/cloud-init.yaml @@ -269,7 +269,7 @@ write_files: docker rm app-happydomain } - docker run -d --restart unless-stopped --network local -e HAPPYDOMAIN_BIND -e HAPPYDOMAIN_CUSTOM_HEAD_HTML -e HAPPYDOMAIN_DEFAULT_NS -e HAPPYDOMAIN_EXTERNALURL -e HAPPYDOMAIN_JWT_SECRET_KEY -e HAPPYDOMAIN_NEWSLETTER_SERVER_URL -e HAPPYDOMAIN_NEWSLETTER_ID -e HAPPYDOMAIN_MAIL_FROM -e HAPPYDOMAIN_MAIL_SMTP_HOST -e HAPPYDOMAIN_MAIL_SMTP_PORT -e HAPPYDOMAIN_MAIL_SMTP_USERNAME -e HAPPYDOMAIN_MAIL_SMTP_PASSWORD -e HAPPYDOMAIN_OVH_APPLICATION_KEY -e HAPPYDOMAIN_OVH_APPLICATION_SECRET -e HAPPYDOMAIN_STORAGE_ENGINE -p "8081:8081" --log-driver syslog --log-opt "syslog-address=unixgram:///dev/log" --log-opt syslog-facility=daemon --log-opt tag=app-happydomain --name app-happydomain --pull always happydomain/happydomain:${HAPPYDOMAIN_VERSION} + docker run -d --restart unless-stopped --network local -v /var/lib/happydomain:/data -e HAPPYDOMAIN_BIND -e HAPPYDOMAIN_CUSTOM_HEAD_HTML -e HAPPYDOMAIN_DEFAULT_NS -e HAPPYDOMAIN_EXTERNALURL -e HAPPYDOMAIN_JWT_SECRET_KEY -e HAPPYDOMAIN_NEWSLETTER_SERVER_URL -e HAPPYDOMAIN_NEWSLETTER_ID -e HAPPYDOMAIN_MAIL_FROM -e HAPPYDOMAIN_MAIL_SMTP_HOST -e HAPPYDOMAIN_MAIL_SMTP_PORT -e HAPPYDOMAIN_MAIL_SMTP_USERNAME -e HAPPYDOMAIN_MAIL_SMTP_PASSWORD -e HAPPYDOMAIN_OVH_APPLICATION_KEY -e HAPPYDOMAIN_OVH_APPLICATION_SECRET -e HAPPYDOMAIN_STORAGE_ENGINE -p "8081:8081" --log-driver syslog --log-opt "syslog-address=unixgram:///dev/log" --log-opt syslog-facility=daemon --log-opt tag=app-happydomain --name app-happydomain --pull always happydomain/happydomain:${HAPPYDOMAIN_VERSION} path: /root/launch_container_app.sh permissions: 0o755 - content: | From 93404eab2deaa362d1cfa7acb455acae50cbe687 Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Fri, 8 Nov 2024 08:12:34 +0100 Subject: [PATCH 3/3] Reduce memory footprint during backup --- cloud-init.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cloud-init.yaml b/cloud-init.yaml index 8b77879..a6c9883 100644 --- a/cloud-init.yaml +++ b/cloud-init.yaml @@ -188,8 +188,13 @@ write_files: mkdir -p /var/backups/happydomain + # Reduce memory footprint during backup + docker stop pdns-demo-happydomain + docker exec -i app-happydomain hadmin /api/backup.json -X POST > /var/backups/happydomain/db.json + docker start pdns-demo-happydomain + restic backup /var/backups/happydomain path: /etc/cron.daily/backup_happydomain permissions: 0o755