Upgrade from Debian 9 (stretch) to Debian 11 (bullseye).

First check your Debian version with:

$ cat /etc/debian_version

Since direct upgrades from Debian releases older than 10 to Debian 11 are not supported, you need to upgrade to Debian 10 (buster) first.

This means that the following steps need to be performed twice, with the replacement of codename.

# First, ensure your system is up-to-date in it's current release.
$ sudo apt update
$ sudo apt upgrade

# If you haven't already, ensure all backups are up-to-date.  

# In a text editor, replace the codename of your release with that of the next release in APT's package sources
# For instance, the line
#    deb https://deb.debian.org/debian/ buster main
# should be replaced with
#    deb https://deb.debian.org/debian/ bullseye main
$ sudo nano /etc/apt/sources.list /etc/apt/sources.list.d/*

# Clean and update package lists
$ sudo apt clean
$ sudo apt update

# Perform the major release upgrade, removing packages if required
# Interrupting this step after downloading has completed is an excellent way to stress-test your backups
$ sudo apt full-upgrade

# Remove packages that are not required anymore
# Be sure to review this list: you may want to keep some of them
$ sudo apt autoremove

# Reboot to make changes effective (optional, but recommended)
$ sudo shutdown -r now

Now check the output of uname -a ; lsb_release -a and you should see info about the upgraded system.

References: