Scripts, services, and timers – OH, MY!

Blank lines removed – they should probably be added back as desired for readability.

/usr/lib/systemd/system/updatewordpress.service:
[Unit]
Description=Run WordPress update script
[Service]
Type=oneshot
ExecStart=/root/updatewp.sh

/usr/lib/systemd/system/updatewordpress.timer:
[Unit]
Description=Check for wordpress update daily
[Timer]
OnCalendar=daily
Persistent=true
[Install]
WantedBy=timers.target

/usr/lib/systemd/system/certbot-renew.service:
[Unit]
Description=Update SSL certs
[Service]
Type=oneshot
ExecStart=/usr/bin/sleep $((RANDOM % 86400)) && /usr/bin/certbot renew

/usr/lib/systemd/system/certbot-renew.timer:
[Unit]
Description=Update SSL certs monthly
[Timer]
OnCalendar=*-*-26 00:00:00
Persistent=true
[Install]
WantedBy=timers.target

/usr/lib/systemd/system/webbackups.service:
[Unit]
Description=Run WordPress backup script
[Service]
Type=oneshot
ExecStart=/root/backups.sh

/usr/lib/systemd/system/webbackups.timer:
[Unit]
Description=Run webbackups script weekly
[Timer]
OnCalendar=Sun *-*-* 06:00:00
Persistent=true
[Install]
WantedBy=timers.target

updatewp.sh:
rm /root/latest.tar.gz
wget -O /root/latest.tar.gz https://wordpress.org/latest.tar.gz
if ! cmp /root/latest.tar.gz /srv/http/wordpress.tar.gz >/dev/null 2>&1; then
rm /srv/http/wordpress.tar.gz
rm -rf /srv/http/wordpress
cp /root/latest.tar.gz /srv/http/wordpress.tar.gz
tar xf /srv/http/wordpress.tar.gz -C /srv/http/
cp -R /srv/http/wordpress/* /srv/http/wp_site1/
chown -R http:http /srv/http/wp_site1
cp -R /srv/http/wordpress/* /srv/http/wp_site2/
chown -R http:http /srv/http/wp_site2
echo "Updated wp at " >> /root/wpstatus.log
date >> /root/wpstatus.log
else
echo "No update needed at " >> /root/wpstatus.log
date >> /root/wpstatus.log
fi

backups.sh:
mkdir /backups/uncomp$(date +%Y%m%d)
cp -r /srv/http /backups/uncomp$(date +%Y%m%d)
cp -r /etc/httpd /backups/uncomp$(date +%Y%m%d)
cp -r /etc/letsencrypt /backups/uncomp$(date +%Y%m%d)
/usr/bin/mysqldump -u backmeup -p### --databases wordpress1 > /backups/uncomp$(date +%Y%m%d)/wordpress1.sql
/usr/bin/mysqldump -u backmeup -p### --databases wordpress2 > /backups/uncomp$(date +%Y%m%d)/wordpress2.sql
tar czf /backups/comp$(date +%Y%m%d).tar.gz /backups/uncomp$(date +%Y%m%d)
tar ztvf /backups/comp$(date +%Y%m%d).tar.gz > /dev/null &&
rm -rf /backups/uncomp$(date +%Y%m%d)

And on my home workstation, this runs a couple of hours after the backups.sh script:

receivebackups.sh:
for x in ssh root@server ls /backups/; do
scp root@server:/backups/$x /webbackups
tar ztvf /webbackups/$x > /dev/null &&
ssh root@server rm /backups/$x
done

My notes for future me