Minimal automated updates for Alpine Linux

Many Linux distros have a way to configure automated updates but somewhat surprisingly Alpine Linux does not.

Alpine Linux
Author
Isaac Bythewood Isaac Bythewood
July 16, 2022

Alpine Linux does run a hardened kernel, I always add a firewall to my servers, lock down SSH access to my IP address, and follow various other server security best practices so I shouldn't have any security problems but I do like to keep things updated.

I've found a very straight forward way of keeping my Alpine Linux servers up-to-date. For every new Alpine Linux server I make I always create a simple shell script in my /etc/periodic/daily/ folder named apk-autoupgrade with the permissions 700:

You can create this yourself or run the following to create it in a single command:

Your Alpine Linux server now auto-updates itself, assuming you have cron jobs running. You can also enable those easily with:

What my script does is run the command apk upgrade --update once a day. Luckily apk by default never asks for user input so it should always just work. The rest of the script is to help you out by providing some logging. You can check the /var/log/apk-autoupgrade.log file every now and then to make sure everything is running smoothly. As an example of the output here's one of my servers:

The one thing this script doesn't do is restart services once they are updated so that's something you'll need to determine yourself. In the future I may expand upon the script by checking for kernel updates or updates to running services and reboot the system or the service based off of the log output. As of right now I automatically reboot my servers every Sunday night since reboots happen almost instantly. If I hear of something critical then I'll just run a quick manual reboot.

That's it, a minimal solution to keep your Alpine Linux systems updated.


Related posts

Some posts in similar tags to this one.

OpenSSH logo
Generating a ED25519 SSH key with OpenSSH
OpenSSH has deprecated RSA keys. Time to swap to ED25519 with a few quick commands as well as an easy way to ease into the swap with host key configurations.
Isaac Bythewood Isaac Bythewood
May 07, 2022
Borg backup logo
Set up automated server backups with Borg
The Borg deduplicating backup program can automate daily, weekly, and monthly backups with a single script saving space and keeping data safe from mistakes.
Isaac Bythewood Isaac Bythewood
June 25, 2022
© 2022 Isaac Bythewood. Some rights reserved.