There is a new version of this tutorial available for Debian 10 (Buster).

How to Upgrade Debian 8 (Jessie) to 9 (Stretch) safely

This tutorial explains the procedure to upgrade Debian 8 to 9 in a few simple steps.

Before you start with the upgrade, backup all critical data. That's especially the config data in the /etc directory and the user data in /home. When you run a server then you should include the databases (MySQL, Postgresql, etc), web and email data in the backup as well. The backup should be stored on an external hard disk, on an external server e.g. by FTP or on a cloud drive. Here are a few examples of how to create backups with tar.

Backup the configuration and data

Configuration files in the /etc directory.

tar -pczf etc.tar.gz /etc

Backup of the /var/www website directory.

tar -pczf www.tar.gz /var/www

Backup of the /home directories.

tar -pczf home.tar.gz /home

For ISPConfig 3 users: Backup of your email server files.

tar -pczf vmail.tar.gz /var/vmail

Backup MySQL databases.

mysqldump --defaults-file=/etc/mysql/debian.cnf -cCeQ --hex-blob --quote-names --routines --events --triggers --all-databases -r all_databases.sql

Then move the tar.gz and .sql files for safe storage on a backup drive.

Check the apt sources.list file

We will install all available Jessie updates first before we upgrade to Jessie. On some systems, the package source is defined as "stable" in the sources.list file instead of "jessie" or "stretch". To avoid an accidental early upgrade to Stretch, please check the sources.list now and ensure that it contains "jessie" and not "stable" as source:

Use a command line editor like nano or vi to open /etc/apt/sources.list, the lines should be similar to the ones below:

nano /etc/apt/sources.list
deb http://httpredir.debian.org/debian jessie main contrib non-free
deb http://httpredir.debian.org/debian jessie-updates main contrib non-free
deb http://security.debian.org jessie/updates main contrib non-free

Update the packages for Debian 8

The following commands will install all pending Jessie updates. This ensures that your system is in a good shape for the update to Stretch.

apt-get update

Ready for the first upgrade:

apt-get upgrade

Follow this with:

apt-get dist-upgrade

Check the package state to ensure that no packages are on hold or in half installed state

This test is important, we will check the package state to ensure that no packages are on hold or in half installed state. Your system and apt database must be in a good shape before we proceed with the dist upgrade. If there are any broken or "on hold" packages, then fix these issues before the upgrade.

Check that no packages are on hold by querying the package database with the dpkg command:

dpkg --audit
dpkg --get-selections | grep hold

When both commands did not return any packages, then proceed with the upgrade.

Update the sources.list for Debian 9

Edit the /etc/apt/sources.list file again:

nano /etc/apt/sources.list

and replace its content with the following lines:

deb http://httpredir.debian.org/debian stretch main contrib non-free
deb http://httpredir.debian.org/debian stretch-updates main contrib non-free
deb http://security.debian.org stretch/updates main contrib non-free

Save the file and run the following command to update the sources database:

apt-get update

Check if packages are upgradable

We can test with apt command if the installed packages are upgradable. Run this command to perform the test:

 apt list --upgradable

Debian 8 to 9 Update in two steps

It is recommended to do the upgrade in two steps, first run "apt-get upgrade" to install the base packages and then run "apt-get dist-upgrade" to do the actual distribution upgrade,

Start with the update by running this command:

apt-get upgrade

Next, we will do the distribution upgrade by running:

apt-get dist-upgrade

A reboot is required to finish the upgrade and load the new kernel:

reboot

Check the update

To check which Debian version is currently installed on the system, take a look at the file /etc/os-release.

cat /etc/os-release

The result on a Debian Stretch system is:

Debian updated to version 9

Share this page:

Suggested articles

32 Comment(s)

Add comment

Comments

By: diablo666

Works with ispconfig installed right?

Something to do for that?

By: Ben

Some optional cleanup steps, before editing sources...

apt-get --purge remove `deborphan`  (purge some unneeded packages - repeat until nothing is removed )

apt-get --purge autoremove  ( purge auto-installed packages)

aptitude search "~o"  (to find obsolete packages, which might be worth removing)

By: Tomas

Will this upgrade the kernel as well? It looks like it does not.

By: till

Yes, a dist upgrade will upgrade the Linux Kernel,

By: Grant

I would add one step. After doing the update, but before the upgrade do "apt-get dist-upgrade -d"  Having everything downloaded and local before you start can be a significant benefit, not dealing with network issues during an upgrade.

By: peter3332

Will this work over 2 versions from debian 7 to 9  or i shoud do 7 -> 8 -> 9 ?

By: till

I won't skip a release in the upgrade process. But it might work, just haven't tested that.

By: SamTzu

I would remove fail2ban before upgrading. It usually brakes during upgrade.

By: pattone

What is better.... "apt-get update && apt-get upgrade"  or "apt update && apt upgrade" ??

By: toto1988

Thank you! :)

By: simon

work ok 

Thank

By: Z3r0h0ur

Postfix is not working after upgrade, as it's upgrading from 2.x to 3.x . Couldn't find a fix for that yet (

By: c3n

The postfix issue is created because of spamd and spamassassin demon. Try to stop those services, then restart postfix service -- everything should be fine. If not, check hostname, hosts, mailname for errors. On most of my servers i had to remove spamd and spamassassin and everything is working fine.

By: Jos

All went well with the above help but....IP address doesn't work anymore, both sites now offline! ISConfig gives empty screen. Please help.Jos..

By: till

Run an ISPConfig update and choose yes when the updater asks you to reconfigure services.

By: Spacestar54

Still can't reply. Is this the update line: ispconfig_update.sh Doesn't help. Jos...

By: Jos

Can't reply. But update did not solved the problem.

By: till

I have no Idea why you write into each reply while sending the reply. But back to your topic, if you need further help, then please make a thread in the ispconfig forum here at howtoforge with the exact errors that you get in the log files of the failed services.

By: David

I did the upgrade as recommanded.

After an initial panic (maria-db wouldn't work), I rebooted the server it came back fine.

I had to uninstall and reinstall fail2ban to make it work (with new config).

I only found one minor problem:In "Server Load" the "Users Online" stays to 0 even when I'm connected with SSH

By: Francis Rodrigues

Por que usar "main contrib non-free" e não o default "main"?

By: HitoDev

Hello,

I followed this guide.

During Debian 8 upgrade, at the end, I got:

*****************************

Preparing to unpack .../mariadb-client_10.1.38-0+deb9u1_all.deb ...Unpacking mariadb-client (10.1.38-0+deb9u1) over (10.0.30-0+deb8u2) ...Preparing to unpack .../mariadb-server_10.1.38-0+deb9u1_all.deb ...Unpacking mariadb-server (10.1.38-0+deb9u1) over (10.0.30-0+deb8u2) ...(Reading database ... 64480 files and directories currently installed.)Removing mariadb-server-10.0 (10.0.30-0+deb8u2) ...6623There is a MySQL server running, but we failed in our attempts to stop it.Stop it yourself and try again!dpkg: error processing package mariadb-server-10.0 (--remove): subprocess installed pre-removal script returned error exit status 1dpkg: mariadb-client-10.0: dependency problems, but removing anyway as you requested: mariadb-server-10.0 depends on mariadb-client-10.0 (>= 10.0.30-0+deb8u2); however:  Package mariadb-client-10.0 is to be removed. roundcube-mysql depends on mariadb-client | mysql-client | virtual-mysql-client; however:  Package mariadb-client is not configured yet.  Package mysql-client is not installed.  Package virtual-mysql-client is not installed.  Package mariadb-client-10.0 which provides virtual-mysql-client is to be removed.Removing mariadb-client-10.0 (10.0.30-0+deb8u2) ...Removing mariadb-client-core-10.0 (10.0.30-0+deb8u2) ...Processing triggers for man-db (2.7.6.1-2) ...Errors were encountered while processing: mariadb-server-10.0E: Sub-process /usr/bin/dpkg returned an error code (1)You have new mail in /var/mail/root

*****************************

This is a Debian 8 / ispConfig server.

what am I supposed to do?

Nees I stop 'manualy' mysql and run again ?

apt-get dist-upgrade

 

 

By: AMPSYS

Didn't see a response to diablo666's question below:  Is this safe with ISPCONFIG installed?

 

I have a multiserver setup (Web, NS1, NS2, and SQL) that are all running 8 @ 3.1.13p1 that I'd like to upgrade to 9.

 

Thanks.

By: till

Dist upgrades are never 100% save as you replace basically all software on your servers, no matter which instructions you use, so always do a backup first. There is always something that can go wrong. Thus said, I've updated several ISPConfig servers using this procedure successfully. First follow this guide, and then do an ispconfig update with reconfigure services = yes on the system to adapt the config files.

By: AMPSYS

Tried this and it broke DNS on my ISPCONFIG 3.1.13p1 multi-server setup.  Fortunately, I took a snapshot prior and was able to revert back rather quickly.

By: Ammad

Is it possible, upgrade from Debian 8 directly to Debian 10? How safe is it? 

By: Han

I'm trying to follow your guide, but after doing apt-get upgrade i'm getting :  0 upgraded, 0 newly installed, 0 to remove and 395 not upgraded.

should i just start with the dist-upgrade or should i break off the upgrade entirely ?

By: ben

Thank you

You saved my day and learnt to me new thing

By: Geoff

Many thanks for the guidance.  Worked first time on a webmin/virtualmin installation.

What about Debian 9 to Debian 10?

By: Baba

Postfix was not working after update to strech. To fix this issue You have to change: daemon_directory = /usr/lib/postfix to daemon_directory = /usr/lib/postfix/sbin This fixed my issues after update.

By: Mike

I updated Debian 8 with ISPConfig 3.1 to Debian 9 according to this guide. The update was successful, no errors, but PHP 5.6 remained installed on the server. The PHP 7.0 distribution did not install completely, so I installed the missing packages from The Perfect Server - Debian 9 (Stretch) with Apache, BIND, Dovecot, PureFTPD and ISPConfig 3.1 here on howtoforge. I updated ISPConfig 3.1 to version 3.2. In ISPConfig in Server Config on the Web tab on the PHP Settings tab, the values for PHP 5 remain:

Apache php.ini path: - /etc/php5/apache2/php.iniCGI php.ini path: - /etc/php5/cgi/php.iniPHP-FPM init script: - php5-fpmPHP-FPM php.ini path: - /etc/php5/fpm/php.iniPHP-FPM pool directory: - /etc/php5/fpm/pool.dPHP-FPM start port: - 9010PHP-FPM socket directory: - /var/lib/php5-fpmPHP open_basedir: - [website_path]/web:[website_path]/private:[website_path]/tmp:/var/www/[website_domain]/web:/srv/www/[website_domain]/web:/usr/share/php5:/usr/share/php:/tmp:/usr/share/phpmyadmin:/etc/phpmyadmin:/var/lib/phpmyadmin:/dev/random:/dev/urandom

In the FastCGI tab, the following remain:

FastCGI starter path: - /var/www/php-fcgi-scripts/[system_user]/FastCGI starter script: - .php-fcgi-starterFastCGI Alias: - /php/FastCGI php.ini Path: - /etc/php5/cgi/FastCGI Children: - 8FastCGI max. Requests: - 5000FastCGI Bin: - /usr/bin/php-cgi

Apache is still running with PHP 5.6 and even the PHP 7: 0 mod module is not allowed, only PHP 5. I need to switch to the PHP 7.0 distribution and get rid of PHP 5.6 completely. Can someone please send me the correct values and paths for the PHP 7.0 distribution in Debian Stretch? Thank you very much for your help.

 

By: blablabla

Hello and how i can fix if this return a package hold? dpkg --get-selections | grep hold return owncloud-files Ive try apt install owncloud-files Lecture des listes de paquets... Fait Construction de l'arbre des dépendances Lecture des informations d'état... Fait owncloud-files est déjà la plus récente version disponible. owncloud-files passé en « installé manuellement ». Thanks for any help I'l need to upgrade for letsencrypt :x

By: Azfar

how to perform upgrade in 2022? getting jey errors.

 

W: There is no public key available for the following key IDs:0E98404D386FA1D9W: Failed to fetch http://httpredir.debian.org/debian/dists/stretch-updates/contrib/binary-amd64/Packages  404  Not Found [IP: 199.232.26.132 80]W: Failed to fetch http://httpredir.debian.org/debian/dists/stretch/main/binary-amd64/Packages  404  Not Found [IP: 199.232.26.132 80]W: Failed to fetch http://httpredir.debian.org/debian/dists/stretch/non-free/binary-amd64/Packages  404  Not Found [IP: 199.232.26.132 80]