Script to upgrade Debian systems

[blog poststandalone]

Upgrading Debian GNU/Linux can be a tedious task if you have several servers that need to be upgraded. I had many servers that required an OS upgrade and I couldn't find a tool to ease the upgrade.

I know that automating the upgrade is very complex as it depends on the status of the server packages. Things like using third party repositories or manually installed packages will most likely cause troubles during an Debian version upgrade. However, I decided to code an script to help me upgrade servers that met the following requirements:

The script I coded is called simply debian_upgrade.sh and this is how it looks.

2021/assets/debian_upgrade.png

The script is available in my github tools repository.

I've already upgraded many servers with it and it worked surprisingly well im the vast majority of my installations, having most of them upgraded in a matter of 30 minutes.

As an example of how I upgraded my LEMP servers, this is the command that I used in all of them: ./debian_upgrade.sh -p 'env DEBIAN_FRONTEND=noninteractive APT_LISTCHANGES_FRONTEND=mail apt-get purge -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" php* && pip uninstall -y docker docker-py docker-pycreds ; sed -i "s/^innodb_additional_mem_pool_size.*//g" /etc/mysql/my.cnf && systemctl restart mysql'

Here I apply some needed modifications to clean things up before the upgrade. After the upgrade finishes I just need to run my Ansible playbook to install all missing packages and configurations.

I hope you find this tool useful. Please feel free to send some feed back via github or just contact me.