2023-12-07 10:16:46 +01:00
{ pkgs , . . . }: {
2024-05-01 09:24:11 +02:00
services . cron = {
enable = true ;
systemCronJobs = [
# Backups to nuc-docker01
'' 0 0 * * * r o o t r s y n c - - d e l e t e - a v r / S t o r a g e / D a t a / D o c k e r / s y s c t l . i o / r o o t @ n u c - d o c k e r 0 1 : / S t o r a g e / D a t a / D o c k e r / s y s c t l . i o / ''
'' 0 3 * * * r o o t r s y n c - a v r / S t o r a g e / D a t a / D o c k e r / s y s c t l . i o / n e x t c l o u d / h t m l / d a t a / a l b e r t / f i l e s / I n s t a n t U p l o a d / r o o t @ n u c - d o c k e r 0 1 : / S t o r a g e / V i d e o / P i c t u r e s / I n s t a n t U p l o a d / ''
'' 0 5 * * * r o o t r s y n c - a v r / S t o r a g e / D a t a / D o c k e r / s y s c t l . i o / n e x t c l o u d / h t m l / d a t a / a l b e r t / f i l e s / W a l l p a p e r s / r o o t @ n u c - d o c k e r 0 1 : / S t o r a g e / V i d e o / P i c t u r e s / W a l l p a p e r s ''
# Back up the docker containers monthly:
'' @ m o n t h l y r o o t s s h n u c - d o c k e r 0 1 " r m - r f / S t o r a g e / B a c k u p s / D o c k e r / s y s c t l . i o / * " ; f o r i i n $( d o c k e r p s - - f o r m a t ' { { . N a m e s } } ' ) ; d o d o c k e r e x p o r t $i | g z i p - c f | s s h r o o t @ n u c - d o c k e r 0 1 " c a t > / S t o r a g e / B a c k u p s / D o c k e r / s y s c t l . i o / $i . t a r . g z " ; d o n e ''
# Set a random Pi-Hole password
'' * * * * * r o o t d o c k e r e x e c p i h o l e s u d o p i h o l e - a - p $( o p e n s s l r a n d - h e x 1 2 8 ) ''
# Run the ClamAV scan
'' @ m o n t h l y r o o t / S t o r a g e / D a t a / d o c k e r - c o m p o s e / s y s c t l . i o / s c r i p t s / c l a m s c a n - c r o n . s h ''
# Archive Loki logs monthly
'' @ m o n t h l y r o o t / S t o r a g e / D a t a / d o c k e r - c o m p o s e / s y s c t l . i o / s c r i p t s / b a c k u p - l o g s . s h > > / S t o r a g e / D a t a / T e m p o r a r y / l o g _ b a c k u p s . l o g ''
# Run the Nextcloud cronjobs hourly
'' @ h o u r l y r o o t d o c k e r e x e c - u w w w - d a t a n e x t c l o u d p h p - f / v a r / w w w / h t m l / c r o n . p h p ''
# Run the Pixelfed scheduler
'' * * * * * r o o t d o c k e r e x e c p i x e l f e d - a p p p h p a r t i s a n s c h e d u l e : r u n ''
# Update / CLean Mastodon caches
'' @ d a i l y r o o t d o c k e r e x e c m a s t o d o n - w e b t o o t c t l p r e v i e w _ c a r d s r e m o v e - - d a y s 7 ''
'' @ d a i l y r o o t d o c k e r e x e c m a s t o d o n - w e b t o o t c t l m e d i a r e m o v e - - d a y s 7 - - p r u n e - p r o f i l e s ''
'' @ d a i l y r o o t d o c k e r e x e c m a s t o d o n - w e b t o o t c t l a c c o u n t s p r u n e ''
'' @ d a i l y r o o t d o c k e r e x e c m a s t o d o n - w e b t o o t c t l s t a t u s e s r e m o v e - - d a y s 7 ''
'' @ d a i l y r o o t d o c k e r e x e c m a s t o d o n - w e b t o o t c t l m e d i a r e m o v e - - r e m o v e - h e a d e r s - - i n c l u d e - f o l l o w s - - d a y s 7 ''
'' @ d a i l y r o o t d o c k e r e x e c m a s t o d o n - w e b t o o t c t l p r e v i e w _ c a r d s r e m o v e - - d a y s 7 ''
'' @ d a i l y r o o t d o c k e r e x e c m a s t o d o n - w e b t o o t c t l m e d i a r e m o v e - o r p h a n s ''
] ;
} ;
2024-01-02 13:26:44 +01:00
}
2023-12-08 11:18:06 +01:00
# Old crontab:
# # At reboot, apply the ip_tables modprobe so Wireguard works
# @reboot /usr/sbin/modprobe ip_tables
#
# # At reboot, restart Docker. Otherwise, iptables / the firewall freaks out
# @reboot /usr/bin/systemctl stop docker; /usr/bin/systemctl start docker
#
# # Every day, get storage space for monitoring
# @daily source ~/.bashrc; for i in `ls /Storage/Data/Docker`; do echo echo "$(date): $(du -s /Storage/Data/Docker/$i)" | sed -e 's/\/Storage\/Data\/Docker\/\$i//' >> /root/sizes/$i.log; done
#
# # Clean up NextCloud files weekly to save space
# @weekly source ~/.bashrc; /usr/bin/docker exec -uwww-data nextcloud php occ versions:cleanup
2023-12-27 12:54:13 +01:00
# DONE # Run the Nextcloud cronjobs hourly
# DONE @hourly source ~/.bashrc; /usr/bin/docker exec -uwww-data nextcloud php -f /var/www/html/cron.php
2023-12-08 11:18:06 +01:00
#
#
# # Clear out Mastodon caches daily
2023-12-27 12:54:13 +01:00
# DONE @daily source ~/.bashrc; /usr/bin/docker exec mastodon-web tootctl preview_cards remove --days 1
# DONE @daily source ~/.bashrc; /usr/bin/docker exec mastodon-web tootctl media remove --days 1 --prune-profiles
# DONE @daily source ~/.bashrc; /usr/bin/docker exec mastodon-web tootctl accounts prune
# DONE @daily source ~/.bashrc; /usr/bin/docker exec mastodon-web tootctl statuses remove --days 1
# DONE @daily source ~/.bashrc; /usr/bin/docker exec mastodon-web tootctl media remove --remove-headers --include-follows --days 0
# DONE @daily source ~/.bashrc; /usr/bin/docker exec mastodon-web tootctl preview_cards remove --days 1
# DONE @daily source ~/.bashrc; /usr/bin/docker exec mastodon-web tootctl media remove-orphans
2023-12-08 11:18:06 +01:00
#
2023-12-27 12:54:13 +01:00
# DONE # Run the Pixelfed scheduler
# DONE * * * * * /usr/bin/docker exec pixelfed-app php artisan schedule:run
2023-12-08 11:18:06 +01:00
#
2023-12-27 12:54:13 +01:00
# DONE # Run the ClamAV scan
# DONE @monthly source ~/.bashrc; /Storage/Data/docker-compose/sysctl.io/scripts/clamscan-cron.sh
2023-12-08 11:18:06 +01:00
#
2023-12-27 12:54:13 +01:00
# DONE # Set a random PiHole password every minute
# DONE * * * * * /usr/bin/docker exec pihole sudo pihole -a -p $(openssl rand -hex 128)
2023-12-08 11:18:06 +01:00
#
2023-12-27 12:54:13 +01:00
# NOT NEEDED # back up crontab:
# NOT NEEDED # 0 0 * * * /usr/bin/crontab -l > /Storage/Data/Temporary/crontab
2023-12-08 11:18:06 +01:00
#
# # Back up and delete local copies of Loki logs monthly
2023-12-27 12:54:13 +01:00
# DONE @monthly source ~/.bashrc; /Storage/Data/docker-compose/sysctl.io/scripts/backup-logs.sh >> /Storage/Data/Temporary/log_backups.log
2023-12-08 11:18:06 +01:00
#
2023-12-27 12:54:13 +01:00
# DONE # Back up the docker containers weekly:
# DONE @weekly source ~/.bashrc; ssh nuc-docker01 "rm -rf /Storage/Backups/Docker/sysctl.io/*"; for i in $(docker ps --format '{{.Names}}'); do docker export $i | gzip -cf | ssh root@nuc-docker01 "cat > /Storage/Backups/Docker/sysctl.io/$i.tar.gz"; done
2023-12-08 11:18:06 +01:00
#
# # Set up DERP relay certs for headscale-derp:
2023-12-27 12:54:13 +01:00
# DONE @hourly cp /Storage/Data/Docker/letsencrypt/certs/certs/\*.sysctl.io.crt /Storage/Data/Docker/letsencrypt/certs/certs/derp.sysctl.io.crt
# DONE @hourly cp /Storage/Data/Docker/letsencrypt/certs/private/\*.sysctl.io.key /Storage/Data/Docker/letsencrypt/certs/private/derp.sysctl.io.key