home · contact · privacy
Set up regular microblog.pub DB pruning.
authorChristian Heller <c.heller@plomlompom.de>
Thu, 23 Feb 2023 19:28:43 +0000 (20:28 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Thu, 23 Feb 2023 19:28:43 +0000 (20:28 +0100)
bullseye/etc_files/microblogpub/etc/systemd/system/microblogpub_prune.service [new file with mode: 0644]
bullseye/etc_files/microblogpub/etc/systemd/system/microblogpub_prune.timer [new file with mode: 0644]
bullseye/other_files/prune_microblog.sh [new file with mode: 0644]
bullseye/setup_scripts/setup_microblogpub.sh

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 (file)
index 0000000..9004cc5
--- /dev/null
@@ -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 (file)
index 0000000..d954385
--- /dev/null
@@ -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 (file)
index 0000000..8cfc385
--- /dev/null
@@ -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
index ce0d7d1c6c1bbb8db811cc34625754b18cec43be..d0f68c938fca59b0dbc4f72ae9655e73cd28edea 100755 (executable)
@@ -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
 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