From: Christian Heller Date: Thu, 23 Feb 2023 19:28:43 +0000 (+0100) Subject: Set up regular microblog.pub DB pruning. X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/static/%7B%7Bdb.prefix%7D%7D/%7B%7Bprefix%7D%7D/process?a=commitdiff_plain;h=8a0ed8264d1b884c46dfa1fb5a5862bac6e1aceb;p=config Set up regular microblog.pub DB pruning. --- diff --git a/bullseye/etc_files/microblogpub/etc/systemd/system/microblogpub_prune.service b/bullseye/etc_files/microblogpub/etc/systemd/system/microblogpub_prune.service new file mode 100644 index 0000000..9004cc5 --- /dev/null +++ b/bullseye/etc_files/microblogpub/etc/systemd/system/microblogpub_prune.service @@ -0,0 +1,9 @@ +[Unit] +Description=microblog.pub pruning + +[Service] +Type=simple +ExecStart=/bin/sh -c '.prune.sh' + +[Install] +WantedBy=multi-user.target diff --git a/bullseye/etc_files/microblogpub/etc/systemd/system/microblogpub_prune.timer b/bullseye/etc_files/microblogpub/etc/systemd/system/microblogpub_prune.timer new file mode 100644 index 0000000..d954385 --- /dev/null +++ b/bullseye/etc_files/microblogpub/etc/systemd/system/microblogpub_prune.timer @@ -0,0 +1,9 @@ +[Unit] +Description=schedule microblog.pub pruning + +[Timer] +Unit=reboot.service +OnCalendar=*-*-* 7:00:00 + +[Install] +WantedBy=timers.target diff --git a/bullseye/other_files/prune_microblog.sh b/bullseye/other_files/prune_microblog.sh new file mode 100644 index 0000000..8cfc385 --- /dev/null +++ b/bullseye/other_files/prune_microblog.sh @@ -0,0 +1,10 @@ +#!/bin/sh +set -e +set -x +service microblogpub stop +microblogdir=/home/plom/testing.microblog.pub +cd "${microblogdir}" +cp -r data/microblogpub.db data/microblogpub.db.bak.$(date +%a) +su -lc "cd ${microblogdir} && poetry run inv prune-old-data" - plom +service microblogpub start +echo "last microblog pruning at $(date)" >> /home/plom/prune_log.txt diff --git a/bullseye/setup_scripts/setup_microblogpub.sh b/bullseye/setup_scripts/setup_microblogpub.sh index ce0d7d1..d0f68c9 100755 --- a/bullseye/setup_scripts/setup_microblogpub.sh +++ b/bullseye/setup_scripts/setup_microblogpub.sh @@ -51,3 +51,8 @@ service microblogpub start sed -i "s/REPLACE_fqdn_ECALPER/${domain}/g" /etc/nginx/sites-available/microblogpub.nginx ln -s /etc/nginx/sites-available/microblogpub.nginx /etc/nginx/sites-enabled/microblogpub.nginx service nginx restart + +# Setup regular DB pruning +cp "${config_tree_prefix}/other_files/prune_microblog.sh" /home/plom/ +systemctl enable microblogpub_prune.timer +systemctl start microblogpub_prune.timer