{"id":2764,"date":"2018-01-22T13:43:36","date_gmt":"2018-01-22T10:43:36","guid":{"rendered":"https:\/\/www.howtoforge.com\/tutorial\/how-to-upgrade-debian-8-jessie-to-9-stretch\/"},"modified":"2018-01-22T13:43:36","modified_gmt":"2018-01-22T10:43:36","slug":"how-to-upgrade-debian-8-jessie-to-9-stretch-safely","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/how-to-upgrade-debian-8-jessie-to-9-stretch-safely\/","title":{"rendered":"How to Upgrade Debian 8 (Jessie) to 9 (Stretch) safely"},"content":{"rendered":"<p>This tutorial explains the procedure to upgrade Debian 8 to\u00a09 in a few simple steps.<\/p>\n<p>Before you start with the upgrade, backup all critical data. That&#8217;s especially the config data in the \/etc directory and the user data in \/home. When you run a server then you should\u00a0include\u00a0the databases (MySQL, Postgresql, etc),\u00a0web and email data in the backup as well. The backup should be stored on an external hard disk, on an external\u00a0server e.g. by FTP or on a cloud drive. Here are a few examples of how to create backups with tar.<\/p>\n<h2 id=\"backup-the-configuration-and-data\">Backup the configuration and data<\/h2>\n<p>Configuration files in the \/etc directory.<\/p>\n<p class=\"command\">tar -pczf etc.tar.gz \/etc<\/p>\n<p>Backup of the \/var\/www website directory.<\/p>\n<p class=\"command\"><span>tar -pczf www.tar.gz \/var\/www<\/span><\/p>\n<p><span>Backup of the \/home directories.<\/span><\/p>\n<p class=\"command\"><span>tar -pczf home.tar.gz \/home<\/span><\/p>\n<p>For ISPConfig 3 users: Backup of your email server files.<\/p>\n<p class=\"command\"><span>tar -pczf vmail.tar.gz \/var\/vmail<\/span><\/p>\n<p>Backup MySQL databases.<\/p>\n<p class=\"command\">mysqldump &#8211;defaults-file=\/etc\/mysql\/debian.cnf -cCeQ &#8211;hex-blob &#8211;quote-names &#8211;routines &#8211;events &#8211;triggers &#8211;all-databases -r all_databases.sql<\/p>\n<p>Then move the tar.gz and .sql\u00a0files for safe storage on a backup drive.<\/p>\n<h2 id=\"check-thenbspapt-sourceslist-file\">Check the\u00a0apt sources.list file<\/h2>\n<p>We will install all available\u00a0Jessie updates first before we upgrade to Jessie. On some systems, the package source is defined as &#8220;stable&#8221; in the sources.list file instead of &#8220;jessie&#8221; or &#8220;stretch&#8221;. To avoid an accidental early upgrade to Stretch, please check the sources.list now and ensure that it contains &#8220;jessie&#8221; and not &#8220;stable&#8221; as source:<\/p>\n<p>Use a command line editor like nano or vi to open\u00a0<span class=\"system\">\/etc\/apt\/sources.list,<\/span>\u00a0the lines should be similar to the ones below:<\/p>\n<p class=\"command\">nano\u00a0\/etc\/apt\/sources.list<\/p>\n<pre>deb http:\/\/httpredir.debian.org\/debian jessie main contrib non-free<br\/>deb http:\/\/httpredir.debian.org\/debian jessie-updates main contrib non-free<br\/>deb http:\/\/security.debian.org jessie\/updates main contrib non-free<\/pre>\n<h2 id=\"update-the-packages-for-debian-\">Update the packages for Debian 8<\/h2>\n<p>The following commands will install all pending\u00a0Jessie updates. This ensures that your system is in a good shape for the update to Stretch.<\/p>\n<p class=\"command\">apt-get update<\/p>\n<p>Ready for the first upgrade:<\/p>\n<p class=\"command\">apt-get upgrade<\/p>\n<p>Follow this with:<\/p>\n<p class=\"command\">apt-get dist-upgrade<\/p>\n<h2 id=\"check-the-package-state-to-ensure-that-no-packages-are-on-hold-or-in-half-installed-state\">Check the package state to ensure that no packages are on hold or in half installed state<\/h2>\n<p>This test\u00a0is 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 &#8220;on hold&#8221; packages, then fix these issues before the\u00a0upgrade.<\/p>\n<p>Check that no packages are on hold by querying the package database with the dpkg command:<\/p>\n<p class=\"command\">dpkg &#8211;audit<br \/>dpkg &#8211;get-selections | grep hold<\/p>\n<p>When both commands did not return any packages, then proceed with the upgrade.<\/p>\n<h2 id=\"update-the-sourceslist-for-debian-\">Update the sources.list for Debian 9<\/h2>\n<p>Edit\u00a0the <span class=\"system\">\/etc\/apt\/sources.list<\/span>\u00a0file again:<\/p>\n<p class=\"command\">nano\u00a0\/etc\/apt\/sources.list<\/p>\n<p>and replace its content with the following lines:<\/p>\n<pre>deb http:\/\/httpredir.debian.org\/debian stretch main contrib non-free<br\/>deb http:\/\/httpredir.debian.org\/debian stretch-updates main contrib non-free<br\/>deb http:\/\/security.debian.org stretch\/updates main contrib non-free<\/pre>\n<p>Save the file and run the following command to update the sources database:<\/p>\n<p class=\"command\">apt-get update<\/p>\n<h2 id=\"check-if-packages-are-upgradable\">Check if packages are upgradable<\/h2>\n<p>We can test with apt command if the installed packages are upgradable. Run this command to perform the test:<\/p>\n<p class=\"command\">\u00a0apt list &#8211;upgradable<\/p>\n<h2 id=\"debian-to-update-in-two-steps\">Debian 8 to 9 Update in two steps<\/h2>\n<p>It is recommended to do the upgrade in two steps, first run &#8220;apt-get upgrade&#8221; to install the base packages and then run &#8220;apt-get dist-upgrade&#8221; to do the actual distribution upgrade,<\/p>\n<p>Start with the update by running this command:<\/p>\n<p class=\"command\">apt-get upgrade<\/p>\n<p>Next, we will do the distribution upgrade by running:<\/p>\n<p class=\"command\">apt-get dist-upgrade<\/p>\n<p>A reboot is required to finish the upgrade and load the new kernel:<\/p>\n<p class=\"command\">reboot<\/p>\n<h2 id=\"check-the-update\">Check the update<\/h2>\n<p>To check which Debian version is currently installed on the system, take a look at the file \/etc\/os-release.<\/p>\n<p class=\"command\">cat \/etc\/os-release<\/p>\n<p>The result on a\u00a0Debian\u00a0Stretch system is:<\/p>\n<p><a class=\"fancybox\" id=\"img-debian-8-to-9-upgrade\" href=\"https:\/\/www.howtoforge.com\/images\/wheezy_to_jessie_update\/big\/debian-8-to-9-upgrade.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/01\/how-to-upgrade-debian-8-jessie-to-9-stretch-safely.png\" alt=\"Debian updated to version 9\" width=\"550\" height=\"153\" title=\"\"><\/a><\/p>\n<h2 id=\"links\">Links<\/h2>\n<div>\n<p><b>Share this page:<\/b><\/p>\n<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial explains the procedure to upgrade Debian 8 to\u00a09 in a few simple steps. Before you start with the upgrade, backup all critical data. That&#8217;s especially the config data in the \/etc directory and the user data in \/home. When you run a server then you should\u00a0include\u00a0the databases (MySQL, Postgresql, etc),\u00a0web and email data [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[],"class_list":["post-2764","post","type-post","status-publish","format-standard","hentry","category-36"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/2764","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/comments?post=2764"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/2764\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=2764"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=2764"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=2764"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}