HomeLinuxHow to Undo the Last Yum Update: Easy Rollback Guide

How to Undo the Last Yum Update: Easy Rollback Guide

This guide provides step-by-step instructions for administrators and developers working with CentOS, RHEL, or CloudLinux systems to undo the last Yum update and rollback to the previous stable state. It covers identifying problematic updates, removing them, and reverting to the earlier version.

Undoing YUM Updates: Risks and Consequences

  • Potential dependency conflicts: Reverting a package to an older version may break dependencies, causing software malfunction or failure.
  • System configurations, scripts, or customizations: The rollback process may undo changes introduced by the previous update, leading to unexpected behavior or manual intervention.
  • Impact on data or services: Undoing a YUM update may revert changes to database schemas, configuration files, or other critical system components, disrupting normal application or service operations.
  • Recommendations: Thorough research, understanding the update’s impact, and having a backup strategy to mitigate risks and ensure a successful rollback process.

Methods to Undo the Last Yum Update

The choice of method to undo the last YUM update on your CentOS, RHEL, or CloudLinux system depends on the specific circumstances and control level required. The three methods we have are the following:

  1. Manual rollback using package versions
  2. Using yum history to rollback updates
  3. Restoring from a backup using yum history

1. Manual Rollback using Package Versions

One of the most straightforward methods to undo a YUM update is to manually roll back the affected packages to their previous versions. This approach involves identifying the problematic package(s), determining the previous version(s), and then installing the older version(s) to revert the system to the desired state.

To perform a manual rollback, you can use the yum downgrade command, followed by the package name and the specific version you want to install.

yum downgrade <package name> 

For example, if you need to undo an update to the httpd package, you can use the following command:

yum downgrade httpd-2.4.6-93.el7.x86_64

This command will install the previous version of the httpd package, effectively undoing the recent update.

It’s important to note that when performing a manual rollback, you need to be aware of any dependencies that the affected package(s) may have. Ensure that you also downgrade any dependent packages to their previous versions to avoid compatibility issues.

2. Using Yum History to Rollback Updates

Another method to undo a YUM update is to use the yum history command, which provides a detailed history of all package installations, updates, and removals performed on your system. This approach allows you to easily identify the specific update you want to undo and revert the system to its previous state.

To use yum history for rollback, follow these steps:

  1. Run the yum history list command to view the history of yum transactions.
yum history list
  1. Identify the transaction ID (TID) or the date/time of the update you want to undo.
  2. Use the yum history undo <TID> command to revert the system to the state before the selected transaction.
yum history undo <TID>

For example, if you want to undo the last YUM update, you can use the following command:

 yum history undo last

This command identifies the steps needed to revert the system. It restores the state before the latest YUM transaction.

The yum history approach is helpful for undoing multiple updates. It is also useful when updates have complex dependencies. The YUM history feature ensures that the rollback process correctly handles all the necessary package versions and dependencies.

3. Restoring from a Backup using Yum History

If previous methods are not feasible, you may want a complete system restoration. Consider restoring from a backup. This approach uses the yum history command to identify the backup snapshot for the desired system state. Then, restore the system from that backup.

To restore from a backup using yum history, follow these steps:

  1. Run the yum history list command to view the history of YUM transactions.
yum history list
  1. Identify the transaction ID (TID) or the date/time of the backup snapshot you want to restore.
  2. Use the yum-complete-transaction –undo <TID> command to initiate the restoration process.
yum-complete-transaction --undo <TID>

This command will undo all the YUM transactions that occurred after the selected backup snapshot, effectively restoring your system to its previous state.

It’s important to note that this approach requires you to have a reliable backup of your system, which should be regularly maintained and tested to ensure its integrity. Restoring from a backup can be a more time-consuming process, but it provides a comprehensive way to undo a YUM update and revert your system to a known good state.

Troubleshooting Common Issues During Rollback

When rolling back a YUM update, unexpected issues like dependency conflicts, third-party repository interference, or system configuration changes may arise. These problems can prevent a successful rollback.

1. Dependency Conflicts during YUM HISTORY UNDO Command

A dependency error is shown below, which occurred when a user rollback the system:

This indicates that the httpd package requires a specific version of httpd-tools, which is no longer available. You can manually install the required version of the conflicting package. For example, with the command below, we can manually install the required package version mentioned in the error.

sudo yum install httpd-tools-2.4.6-93.el7.centos.x86_64

After resolving the dependency conflict, attempt the rollback again with the same command you did before:

sudo yum history undo <transaction id>

Sometimes, multiple packages can cause the same problem. Using the –allowerasing option is the best choice here. When using –allowerasing option, YUM will automatically handle the erasure of conflicting packages.

sudo yum history undo <transaction id> --allowerasing
When using --allowerasing option with sudo yum history undo command, there’s a risk of removing packages that might be important for other parts of the system, potentially leading to further issues. Therefore, use it with caution.

2. Third-Party Repository Interference during YUM HISTORY UNDO Command

Third-party repositories can introduce packages that conflict with those in the official repositories. This can complicate rollbacks because the versions of packages available from third-party repositories may differ from those in the official repositories.

To resolve this, you can temporarily disable third-party repositories to avoid conflicts during the execution of the yum history undo command. To list all enabled repositories, execute the command:

yum repolist

After identifying the repositories to disable, execute the following command, replacing <repository_name> with the name of the third-party repository you wish to disable.

sudo yum-config-manager --disable <repository_name>

With the third-party repositories disabled, attempt the rollback again!

3. Reverting System Configuration Changes After RollBack

During an update, configuration files may change, and rolling back a package might not revert these changes, causing inconsistencies. The only solution is to manually replace the current configurations with the old ones.

When updating YUM, YUM saves your modified configuration files with a .rpmsave extension in the same path as your system configuration files (/etc). With these .rpmsave files, you can revert the system configuration files after rollback.

Identify any configuration files that were altered during the update. These files are often located in /etc/. For example, if you updated Apache (httpd), you might check the configuration with:

diff /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.rpmsave

This command compares the current configuration with the saved configuration before the update.
If you need to revert the configuration files to their previous states, just copy the .rpmsave file to the original file. For example:

sudo cp /etc/httpd/conf/httpd.conf.rpmsave /etc/httpd/conf/httpd.conf

This command copies the saved configuration file back to its original location. After restoring the configuration file, remember to reboot the specific service related to the configuration or reboot the system.

These are some troubleshooting steps. However, different issues may arise. Research online and consult professionals for assistance.

By following this guide, you can easily undo the last YUM update, and ensure a more reliable and stable computing environment for your CentOS, RHEL, or CloudLinux systems.

Scroll to Top