Introduction

The yum package manager maintains a history of all yum based transactions i.e. software installation, update and removal operations. This history is kept in an sqlite database (rpmdb) which is available in the /var/lib/yum/history/ directory. The transaction history in the rpmdb can be queried via the yum history command. We would also like to point out that a log of package installs, updates and removals is maintained in a text file as well located at /var/log/yum.log. The file provides one line descriptions about the yum related actions that were performed. But a very interesting facet of the yum transaction history is that transactions can be repeated and reversed and also incomplete transactions can actually be resumed. In this article we’ll be focusing on how we could resume incomplete yum transactions and complete them to fruition.

 

Demonstration

With a basic understanding of how yum transactions are maintained, let’s perform a practical demonstration of how we could resume an incomplete yum transaction. Consider the following operation, we are just installing the openssl package on our system. What if during the installation we loose our network connectivity. This is just a single package so repeating the installation isn’t challenging but if it were an entire system update then redoing the entire task from scratch would be tedious. To simulate an interruption I hit the ctrl+c key to stop the yum package installation.

[root@linuxnix ~]# yum install openssl -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: centos.communilink.net
* epel: ftp.yz.yamagata-u.ac.jp
* extras: mirrors.nju.edu.cn
* jpackage-generic: sunsite.informatik.rwth-aachen.de
* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package openssl.x86_64 1:1.0.1e-60.el7 will be updated
---> Package openssl.x86_64 1:1.0.2k-8.el7 will be an update
--> Processing Dependency: openssl-libs(x86-64) = 1:1.0.2k-8.el7 for package: 1:openssl-1.0.2k-8.el7.x86_64
--> Processing Dependency: libcrypto.so.10(OPENSSL_1.0.2)(64bit) for package: 1:openssl-1.0.2k-8.el7.x86_64
--> Running transaction check
---> Package openssl-libs.x86_64 1:1.0.1e-60.el7 will be updated
---> Package openssl-libs.x86_64 1:1.0.2k-8.el7 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Updating:
openssl x86_64 1:1.0.2k-8.el7 base 492 k
Updating for dependencies:
openssl-libs x86_64 1:1.0.2k-8.el7 base 1.2 M

Transaction Summary
================================================================================
Upgrade 1 Package (+1 Dependent package)

Total download size: 1.7 M
Downloading packages:
No Presto metadata available for base
(1/2): openssl-1.0.2k-8.el7.x86_64.rpm | 492 kB 00:00:02
^C/2): openssl-libs-1.0.2k-8.el7.x86_64.rpm 69% [================================================ ] 263 kB/s | 1.2 MB 00:00:01 ETA

Exiting on user cancel


The log containing the progress of the above interrupted transaction has been saved in /tmp in a file named yum_save_tx.2018-03-02.12-34.RZUTa5.yumtx. This file is a simple text file and we can view it’s contents as shown below.

[root@linuxnix tmp]# cat yum_save_tx.2018-03-02.12-34.RZUTa5.yumtx
1042:a0519537e87fd8256727a6d74fb5ad9c8272e031
0
1
installed:1042:011f3019337bd9ec2d1093e2ff746417ed13669c
4
mbr: openssl-libs,x86_64,1,1.0.1e,60.el7 20
repo: installed
ts_state: ud
output_state: 90
isDep: False
reason: dep
reinstall: False
relatedto: openssl-libs,x86_64,1,1.0.2k,8.el7@a:updatedby
updated_by: openssl-libs,x86_64,1,1.0.2k,8.el7@a
mbr: openssl-libs,x86_64,1,1.0.2k,8.el7 70
repo: base
ts_state: u
output_state: 10
isDep: True
reason: dep
reinstall: False
relatedto: openssl-libs,x86_64,1,1.0.1e,60.el7@i:updates openssl,x86_64,1,1.0.2k,8.el7@a:dependson
depends_on: openssl,x86_64,1,1.0.2k,8.el7@a
updates: openssl-libs,x86_64,1,1.0.1e,60.el7@i
mbr: openssl,x86_64,1,1.0.2k,8.el7 70
repo: base
ts_state: u
output_state: 10
isDep: False
reason: dep
reinstall: False
relatedto: openssl,x86_64,1,1.0.1e,60.el7@i:updates
updates: openssl,x86_64,1,1.0.1e,60.el7@i
mbr: openssl,x86_64,1,1.0.1e,60.el7 20
repo: installed
ts_state: ud
output_state: 90
isDep: False
reason: dep
reinstall: False
relatedto: openssl,x86_64,1,1.0.2k,8.el7@a:updatedby
updated_by: openssl,x86_64,1,1.0.2k,8.el7@a

To resume the transaction we use the load-transaction sub-command with the yum command followed by the complete path to the .yumtx file.

[root@linuxnix tmp]# yum load-transaction /tmp/yum_save_tx.2018-03-02.12-34.RZUTa5.yumtx
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirror.sunnyvision.com
* epel: mirror2.totbb.net
* extras: centos.uhost.hk
* jpackage-generic: sunsite.informatik.rwth-aachen.de
* updates: mirror.sunnyvision.com
Resolving Dependencies
--> Running transaction check
---> Package openssl.x86_64 1:1.0.1e-60.el7 will be updated
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Updating:
openssl x86_64 1:1.0.2k-8.el7 base 492 k
Updating for dependencies:
openssl-libs x86_64 1:1.0.2k-8.el7 base 1.2 M

Transaction Summary
================================================================================
Upgrade 1 Package (+1 Dependent package)

Total size: 1.7 M
Total download size: 1.2 M
Is this ok [y/d/N]: y
Downloading packages:
No Presto metadata available for base
openssl-libs-1.0.2k-8.el7.x86_64.rpm | 1.2 MB 00:00:02
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : 1:openssl-libs-1.0.2k-8.el7.x86_64 1/4
Updating : 1:openssl-1.0.2k-8.el7.x86_64 2/4
Cleanup : 1:openssl-1.0.1e-60.el7.x86_64 3/4
Cleanup : 1:openssl-libs-1.0.1e-60.el7.x86_64 4/4
Verifying : 1:openssl-libs-1.0.2k-8.el7.x86_64 1/4
Verifying : 1:openssl-1.0.2k-8.el7.x86_64 2/4
Verifying : 1:openssl-libs-1.0.1e-60.el7.x86_64 3/4
Verifying : 1:openssl-1.0.1e-60.el7.x86_64 4/4

Updated:
openssl.x86_64 1:1.0.2k-8.el7

Dependency Updated:
openssl-libs.x86_64 1:1.0.2k-8.el7

Complete!

It might not seem obvious from the above command line output but the openssl package installation actually resumed exactly from where I had left it off. If you wish to check if the system has any incomplete transactions and complete them then use the yum-complete-transaction command.

[root@linuxnix ~]# yum-complete-transaction
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: ftp.sjtu.edu.cn
* epel: ftp.yz.yamagata-u.ac.jp
* extras: mirror.lzu.edu.cn
* jpackage-generic: sunsite.informatik.rwth-aachen.de
* updates: mirror.sunnyvision.com
No unfinished transactions left.
[root@linuxnix ~]#

To only cleanup incomplete transactions without resuming them, use the following command.

yum-complete-transaction –cleanup-only

 

Conclusion

This concludes our demonstration of how we could use yums’ transaction history feature to resume incomplete transactions. We hope that you’ve found this demonstration to be useful and we look forward towards your feedback.

The following two tabs change content below.

Sahil Suri

He started his career in IT in 2011 as a system administrator. He has since worked with HP-UX, Solaris and Linux operating systems along with exposure to high availability and virtualization solutions. He has a keen interest in shell, Python and Perl scripting and is learning the ropes on AWS cloud, DevOps tools, and methodologies. He enjoys sharing the knowledge he's gained over the years with the rest of the community.