yum history rollback

Suppose, we have to upgrade the existing PHP package to its higher version. If something goes wrong what is the option now? So, we have an option in Linux where we can rollback the package to its previous version. Let’s see, how to rollback and downgrade update or package using yum history undo command in Linux.

How To Rollback or Downgrade Installed Packages On Linux:

In the demonstration, we will install the PHP 5.4 version which is the default in Linux repository, and later we will update it to the higher version. 

Check Out: Install and Configure S3CMD Tool For Data Sync On S3 Bucket

Let’s begin the installation:

We will Install PHP for our experiment and run the below commands to get PHP 5.4 installed. 

[[email protected] ~]# yum install php -y

you can check the version. 

[[email protected] ~]# php -v
PHP 5.4.16 (cli) (built: Nov 1 2019 16:04:20) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

Upgrade PHP 5.4 to PHP 7.3:

Before installing, we will have to add the Remi repository for PHP 7.3 on Linux using the below commands. 

[[email protected] ~]# yum install epel-release -y
[[email protected] ~]# wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm
[[email protected] ~]# rpm -ivh remi-release-7.rpm 
warning: remi-release-7.rpm: Header V4 DSA/SHA1 Signature, key ID 00f97f56: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:remi-release-7.7-2.el7.remi ################################# [100%]

you will see the Remi repository installed inside this directory /etc/yum.repos.d

[[email protected] ~]# vim /etc/yum.repos.d/remi-php73.repo
[remi-php73]
name=Remi's PHP 7.3 RPM repository for Enterprise Linux 7 - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/7/php73/$basearch/
#mirrorlist=https://rpms.remirepo.net/enterprise/7/php73/httpsmirror
mirrorlist=http://cdn.remirepo.net/enterprise/7/php73/mirror
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

Check Out: Install Tweak Tool On Ubuntu 20.04 LTS Local Fossa Linux

Now you have to enable the PHP7.3 repository and try to install using the same commands. Once its done, check the version installed. It will update the previous version. 

[[email protected] ~]# yum-config-manager --enable remi-php73
[[email protected] ~]# yum install php
[[email protected] ~]# php -v
PHP 7.3.17 (cli) (built: Apr 14 2020 08:29:22) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.17, Copyright (c) 1998-2018 Zend Technologies

Suppose your application has stopped working because it’s compatible with version 7.3 and it’s down now. In this case, we will rollback the previous version 5.4. 

Rollback PHP 7.3 to PHP 5.4:

We can check what we have installed or uninstall using yum commands. it keeps the history of yum.

So, we can check when the package was installed and what package it was. 

yum history undo downgrade

Check Out: How To Enable Haproxy Stats With GUI View On Linux

When you have to check what we have installed. So you can see there is an ID available. we can use this ID to check what we have installed. we had installed the PHP. 

[[email protected] ~]# yum history list 6

rollback linux update

If you need to check the history of ID 6, we can use the below commands. 

[[email protected] ~]# yum history info 6

As you can clearly see, the previous version has been updated to the new one. Now we have to downgrade or rollback it to the lower version.

You can the version using either yum list | grep php or rpm -qa | grep php

Check Out: How To Enable Monitoring of Server On Amazon Cloud

We will use two different commands to downgrade the package both works the same.

  1. using the downgrade commands: 
[[email protected] ~]# yum downgrade package_name.rpm

2. using the yum history commands. The syntax is yum history undo ID 

[[email protected] ~]# yum history undo 6

As we can see we have successfully downgraded the previous version. The above command will remove the current version and install the previous one.

[[email protected] ~]# php -v
PHP 5.4.16 (cli) (built: Nov 1 2019 16:04:20) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

You’re done yum history undo downgrade update rollback linux

LEAVE A REPLY

Please enter your comment!
Please enter your name here