Linux & Docker Admin Scripts
Practical shell scripts and how-tos for running a small Linux and Docker home lab: monitoring, backups, scheduled jobs, certificates and media-library housekeeping.
Monitoring & Server Setup
Monitor server load, disk, CPU and memory with email alerts
A small shell script, run from cron every 5 minutes, that checks four health numbers and emails y...
Auto-create home folders for Active Directory users on RHEL / Rocky
When Linux servers are joined to Active Directory (SSSD or winbind), domain users who log in for ...
A production warning banner, safer aliases and a colour prompt for every login
Drop-in files in /etc/profile.d/ apply to every user's login shell. Here are three small ones. 1....
List listening ports and the programs using them
Before you publish a new container port, check what is already listening. ss shows everything; th...
Email yourself an internet speed test report
Run Ookla's speed test on a Linux box and email the result, for example to keep a record of your ...
Backups
Full operating-system tar backup of a Linux server
A simple bare-bones backup: one compressed tarball of the whole root filesystem, minus the folder...
MySQL / MariaDB backups to a NAS
Dump every database to its own compressed file, keep a few days, and fail loudly when something i...
Store MySQL / MariaDB backup credentials safely
Backup scripts shouldn't contain a database password. Store the login once for the account that r...
Back up every database on several PostgreSQL versions
On RHEL, Rocky and Alma, PGDG packages let PostgreSQL 16 and 17 (for example) run side by side, e...
Set up .pgpass for PostgreSQL backups
If your backups connect over TCP or as a user other than postgres, pg_dump needs a password. Put ...
Back up an OpenProject (package install) to a NAS
The packaged OpenProject (DEB/RPM) has its own backup command. It writes a database dump plus arc...
Back up Docker app SQLite databases without stopping containers
Most self-hosted media apps (Plex, Jellyfin, Sonarr, Radarr, Lidarr, Prowlarr, Bazarr, Tautulli, ...
Back up Docker container data folders (stop, archive, restart)
For apps whose data can't be copied safely while they are running, the simple, reliable method is...
Pull server backups onto a Synology NAS with rsync over SSH
Instead of letting servers write to the NAS, have the NAS pull from them. If a server is compromi...
Scheduling & Certificates
Deploy cron jobs to many servers from one script folder
A lightweight way to manage scheduled jobs on a handful of Linux servers without Ansible. Keep on...
Reliable Let's Encrypt renewals on RHEL / Rocky
A certificate can only be renewed in its last 30 days. A cron job that tries once a month can mis...
Docker & Media Library
A menu script for Docker media containers, with a VPN routing check
If you run a group of media containers (the *arr apps, download clients, flaresolverr and so on),...
Clean up leftover {tmdb-...} folders in a media library
Media managers (Radarr, Sonarr, Jellyfin) name folders like Movie (2020) {tmdb-12345}. When an it...
Remove movie folders that have no video files (safely)
Over time a movie library collects folders that hold only posters, .nfo files or subtitles, becau...
Photos, Files & Raspberry Pi
Set the "date taken" on photos with ExifTool
Scanned or undated photos often have no EXIF date, so photo libraries (Immich, PhotoPrism, Synolo...
Convert images in bulk (convert_images.sh)
Location: /opt/scripts/docker_scripts/convert_images.sh (68 lines) Purpose Converts HEIC photos (...
Delete HEIC files that already have a JPG copy
Location: /opt/scripts/docker_scripts/delete_heic_jpg.sh and /opt/scripts/docker_scripts/delete_j...
Rename all files in a folder to upper case
Location: /opt/scripts/renameuppercase.sh (May 2016, 1 line of logic) Purpose Renames every file ...
Shrink Raspberry Pi SD-card images with PiShrink
Location: /opt/scripts/pishrink.sh (April 2018) Purpose A copy of the open-source PiShrink tool. ...