Fedora DNF rollback RPM package update, removal, installation

Feb 6, 2017 Linux

DNF rollback RPM package update, removal or installation
DNF is a next generation package manager for RPM-based Linux distributions, commonly used in newest Fedora releases. DNF is a Yum succesor, which provides Yum backward compatibility, but one of aspects, which make DNF a powerful package manager is the ability to manage transaction history.

Using DNF, we can easily undo or redo RPM package upgrade, installation and removal. This gives us the opportunity to rollback the system, if we feel, that our recent RPM package operations disordered the system.

Below we presents, how to work with DNF transaction history on Fedora 24.

Example:

Let’s assume, that we mistakenly removed few packages from the system:

[root@fixxxer ~]# dnf remove nload iftop nethogs
Dependencies resolved.
===================================================================================================================================================================================
 Package                                Arch                                  Version                                           Repository                                    Size
===================================================================================================================================================================================
Removing:
 iftop                                  x86_64                                1.0-0.12.pre4.fc24                                @@commandline                                 97 k
 nethogs                                x86_64                                0.8.5-1.fc24                                      @@commandline                                 71 k
 nload                                  x86_64                                0.7.4-7.fc24                                      @@commandline                                166 k

Transaction Summary
===================================================================================================================================================================================
Remove  3 Packages

Installed size: 333 k
Is this ok [y/N]: y

How to check dnf transaction history in Fedora

The below command displays DNF transaction history starting from the latest transaction on top of the listing. It displays transaction IDs along with dates of transaction, types of actions performed and amounts of RPM packages altered:

[root@fixxxer ~]# dnf history
[root@fixxxer ~]# dnf history
ID     | Command line             | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
    88 | remove nload iftop netho | 2017-02-06 22:36 | Erase          |    3   
    87 | update                   | 2017-02-06 21:19 | I, U           |   10   
    86 | erase libxfce4util       | 2017-02-06 21:17 | Erase          |    2   
    85 | erase libxfce4ui         | 2017-02-06 21:17 | Erase          |    4   
    84 | history undo 81          | 2017-02-06 21:08 | Install        |    1   
    83 | history undo 82          | 2017-02-06 21:08 | Install        |    3   
    82 | erase libxfce4ui         | 2017-02-06 21:07 | Erase          |    3   
...

How to display dnf transaction info by transaction ID in Fedora

The latest transaction displayed on top of listing is our erroneous removal of three packages, we can display information about this transaction:

[root@fixxxer ~]# dnf history info 88
Transaction ID : 88
Begin time     : Mon Feb  6 22:36:08 2017
Begin rpmdb    : 2729:e0a8f752eaecfb040362ac6f9cc782ca057909a5
End time       :            22:36:10 2017 (2 seconds)
End rpmdb      : 2726:18555984349147116da4c9e95ab77d7a7a66ef8c
User           : Grzegorz Juszczak 
Return-Code    : Success
Command Line   : remove nload iftop nethogs
Transaction performed with:
    Installed     dnf-1.1.10-4.fc24.noarch @@commandline
    Installed     rpm-4.13.0-1.fc24.x86_64 @@commandline
Packages Altered:
    Erase iftop-1.0-0.12.pre4.fc24.x86_64 @@commandline
    Erase nethogs-0.8.5-1.fc24.x86_64     @@commandline
    Erase nload-0.7.4-7.fc24.x86_64       @@commandline

How to rollback dnf transaction in Fedora

Let’s rollback the latest transaction and using it’s ID and bring back the packages previously removed mistakenly:

[root@fixxxer ~]# dnf history undo 88
Last metadata expiration check: 2:39:37 ago on Mon Feb  6 20:04:15 2017.
Undoing transaction 88, from Mon Feb  6 22:36:08 2017
    Erase iftop-1.0-0.12.pre4.fc24.x86_64 @@commandline
    Erase nethogs-0.8.5-1.fc24.x86_64     @@commandline
    Erase nload-0.7.4-7.fc24.x86_64       @@commandline
===============================================================================================================================================================================================================
 Package                                        Arch                                          Version                                                     Repository                                      Size
===============================================================================================================================================================================================================
Installing:
 iftop                                          x86_64                                        1.0-0.12.pre4.fc24                                          updates                                         55 k
 nethogs                                        x86_64                                        0.8.5-1.fc24                                                updates                                         43 k
 nload                                          x86_64                                        0.7.4-7.fc24                                                fedora                                          73 k

Transaction Summary
===============================================================================================================================================================================================================
Install  3 Packages

Total download size: 171 k
Installed size: 333 k
Is this ok [y/N]: y

Note: RPM package update rollback or erroneous RPM installation rollback runs analogically to the above example.

How to redo (repeat) dnf transaction in Fedora

DNF transaction can be repeated as well using it’s ID:

[root@fixxxer ~]# dnf history redo 89
Last metadata expiration check: 2:50:04 ago on Mon Feb  6 20:04:15 2017.
Repeating transaction 89, from Mon Feb  6 22:44:03 2017
    Install iftop-1.0-0.12.pre4.fc24.x86_64 @updates
    Install nethogs-0.8.5-1.fc24.x86_64     @updates
    Install nload-0.7.4-7.fc24.x86_64       @fedora
===============================================================================================================================================================================================================
 Package                                        Arch                                          Version                                                     Repository                                      Size
===============================================================================================================================================================================================================
Installing:
 iftop                                          x86_64                                        1.0-0.12.pre4.fc24                                          updates                                         55 k
 nethogs                                        x86_64                                        0.8.5-1.fc24                                                updates                                         43 k
 nload                                          x86_64                                        0.7.4-7.fc24                                                fedora                                          73 k

Transaction Summary
===============================================================================================================================================================================================================
Install  3 Packages

Total download size: 171 k
Installed size: 333 k
Is this ok [y/N]: y

Note: DNF operation can be repeated, if it is possible to redo it due to the current state of RPMDB.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.