In RHEL/CentOS 6 and 7, yum has the ability to rollback a previous package operation like update, install or even remove. This is particularly useful if you have done an update that has gone wrong. Redhat though suggests updates to some packages like GLIBC may be tricky and may not work as expected and hence a file system snapshot would give you that extra layer of protection.
Let’s do a simple package install and rollback. I install httpd and its dependency packages here before a rollback.
[root@c7sandbox ~]# yum -q install httpd ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: httpd x86_64 2.4.6-40.el7.centos base 2.7 M Installing for dependencies: apr x86_64 1.4.8-3.el7 base 103 k apr-util x86_64 1.5.2-6.el7 base 92 k httpd-tools x86_64 2.4.6-40.el7.centos base 82 k mailcap noarch 2.1.41-2.el7 base 31 k Transaction Summary ================================================================================ Install 1 Package (+4 Dependent packages) Is this ok [y/d/N]: y
To check on yum history,
[root@c7sandbox ~]# yum history Loaded plugins: fastestmirror ID | Login user | Date and time | Action(s) | Altered ------------------------------------------------------------------------------- 11 | Sai | 2015-12-19 16:50 | Install | 5 10 | Sai | 2015-12-19 16:42 | Install | 1 9 | Sai | 2015-12-19 16:20 | Erase | 40 8 | Sai | 2015-12-19 16:15 | Install | 40 7 | Sai | 2015-12-19 15:52 | Install | 1 6 | Sai | 2015-12-19 12:09 | Install | 1 5 | Sai | 2015-12-19 11:04 | Install | 1 4 | Sai | 2015-12-19 11:04 | Erase | 1 3 | Sai | 2015-12-19 10:37 | I, U | 187 EE 2 | Sai | 2015-12-19 10:32 | Install | 3 1 | System | 2015-12-19 10:17 | Install | 297 history list
ID 11 is the yum operation where we installed httpd here. To find the details
[root@c7sandbox ~]# yum history info 11 Loaded plugins: fastestmirror Transaction ID : 11 Begin time : Sat Dec 19 16:50:31 2015 Begin rpmdb : 306:94476c7cbbd387b46e372f5efd6f0575d117d7fa End time : 16:50:36 2015 (5 seconds) End rpmdb : 311:019668052149a896c21dc6a44bc8b48a4df3197a User : Sai Return-Code : Success Command Line : -q install httpd Transaction performed with: Installed rpm-4.11.3-17.el7.x86_64 @base Installed yum-3.4.3-132.el7.centos.0.1.noarch @base Installed yum-plugin-fastestmirror-1.1.31-34.el7.noarch @base Packages Altered: Dep-Install apr-1.4.8-3.el7.x86_64 @base Dep-Install apr-util-1.5.2-6.el7.x86_64 @base Install httpd-2.4.6-40.el7.centos.x86_64 @base Dep-Install httpd-tools-2.4.6-40.el7.centos.x86_64 @base Dep-Install mailcap-2.1.41-2.el7.noarch @base history info
As you can see the install has worked as expected.
Now to rollback
[root@c7sandbox ~]# yum history undo 11 Loaded plugins: fastestmirror Undoing transaction 11, from Sat Dec 19 16:50:31 2015 Dep-Install apr-1.4.8-3.el7.x86_64 @base Dep-Install apr-util-1.5.2-6.el7.x86_64 @base Install httpd-2.4.6-40.el7.centos.x86_64 @base Dep-Install httpd-tools-2.4.6-40.el7.centos.x86_64 @base Dep-Install mailcap-2.1.41-2.el7.noarch @base Resolving Dependencies --> Running transaction check ---> Package apr.x86_64 0:1.4.8-3.el7 will be erased ---> Package apr-util.x86_64 0:1.5.2-6.el7 will be erased ---> Package httpd.x86_64 0:2.4.6-40.el7.centos will be erased ---> Package httpd-tools.x86_64 0:2.4.6-40.el7.centos will be erased ---> Package mailcap.noarch 0:2.1.41-2.el7 will be erased --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Removing: apr x86_64 1.4.8-3.el7 @base 221 k apr-util x86_64 1.5.2-6.el7 @base 194 k httpd x86_64 2.4.6-40.el7.centos @base 9.4 M httpd-tools x86_64 2.4.6-40.el7.centos @base 168 k mailcap noarch 2.1.41-2.el7 @base 62 k Transaction Summary ================================================================================ Remove 5 Packages Installed size: 10 M Is this ok [y/N]: y Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Erasing : httpd-2.4.6-40.el7.centos.x86_64 1/5 Erasing : httpd-tools-2.4.6-40.el7.centos.x86_64 2/5 Erasing : mailcap-2.1.41-2.el7.noarch 3/5 Erasing : apr-util-1.5.2-6.el7.x86_64 4/5 Erasing : apr-1.4.8-3.el7.x86_64 5/5 Verifying : httpd-2.4.6-40.el7.centos.x86_64 1/5 Verifying : mailcap-2.1.41-2.el7.noarch 2/5 Verifying : apr-util-1.5.2-6.el7.x86_64 3/5 Verifying : httpd-tools-2.4.6-40.el7.centos.x86_64 4/5 Verifying : apr-1.4.8-3.el7.x86_64 5/5 Removed: apr.x86_64 0:1.4.8-3.el7 apr-util.x86_64 0:1.5.2-6.el7 httpd.x86_64 0:2.4.6-40.el7.centos httpd-tools.x86_64 0:2.4.6-40.el7.centos mailcap.noarch 0:2.1.41-2.el7 Complete!
To confirm it worked as expected
[root@c7sandbox ~]# yum history info 12 Loaded plugins: fastestmirror Transaction ID : 12 Begin time : Sat Dec 19 16:53:22 2015 Begin rpmdb : 311:019668052149a896c21dc6a44bc8b48a4df3197a End time : 16:53:23 2015 (1 seconds) End rpmdb : 306:94476c7cbbd387b46e372f5efd6f0575d117d7fa User : Sai Return-Code : Success Command Line : history undo 11 Transaction performed with: Installed rpm-4.11.3-17.el7.x86_64 @base Installed yum-3.4.3-132.el7.centos.0.1.noarch @base Installed yum-plugin-fastestmirror-1.1.31-34.el7.noarch @base Packages Altered: Erase apr-1.4.8-3.el7.x86_64 @base Erase apr-util-1.5.2-6.el7.x86_64 @base Erase httpd-2.4.6-40.el7.centos.x86_64 @base Erase httpd-tools-2.4.6-40.el7.centos.x86_64 @base Erase mailcap-2.1.41-2.el7.noarch @base history info