To upgrade Debian 9 to Debian 10, first make sure your system is up-to-date.
apt update && apt upgrade -y
Edit file /etc/apt/sources.list. Find all occurrences of “stretch” and replace it with “buster”.
sed -i 's/stretch/buster/g' /etc/apt/sources.list
Or use following
deb http://cloudfront.debian.net/debian/ buster main non-free contrib
deb-src http://cloudfront.debian.net/debian/ buster main non-free contrib
deb http://security.debian.org/debian-security buster/updates main contrib non-free
deb-src http://security.debian.org/debian-security buster/updates main contrib non-free
Now update the system
apt update && apt upgrade -y
run dist-upgrade
apt dist-upgrade -y
During the upgrade, you will be asked to replace some of the configuration files. If this is a fresh server, you can always replace these files with a newer version. If your server has these files modified, you should be careful as replacing these files will lose the changes you made.
Reboot the server.
reboot
After reboot, you can verify the server is running Debian 10 with commands
lsb_release -a
hostnamectl