Question: How can I rollback an RPM upgrade of the MySQL Server that I don’t want to keep?
There may be a number of reasons why you need to rollback an upgrade of the server, but the last thing you want is to perform the upgrade, have it fail, and then can’t get back to a working installation again. Some may say that this is why you have backups, but the backup is designed primarily to keep the data consistent and durable over the upgrade. For older RPM installations, the traditional method was to use the –old-package option. For example:
# rpm -Uvh --old-package MySQL-Server-5.1.50.x86-64.rpm
Where the RPM specified here is the package that was running before the upgrade occurred. The –old-package option allowed the packaging system to ignore that an older version was being installed and downgraded the binaries to the earlier version.
With the newer versions of RPM packaging ( 4.4.3 or higher recommended), the option is available to perform a transactional rollback of the package upgrade. To do a rollback, you first have to make sure you perform the upgrade with the –repackage option. This will create a copy package in the /var/spool/repackage directory and enable rollback in the future, if required.
It is important that if you have multiple packages that are being upgraded such as mysql-server, mysql-client, mysql-libs, etc, that you use the –repackage option for each RPM package that you upgrade. So an example on a package upgrade.
# rpm -Uvh --repackage MySQL-Server-5.1.62.x86_64.rpm Preparing... ############################# [100%] Repackaging... 1:MySQL-Server-5.1.62 ############################# [100%] Upgrading... 1:MySQL-Server-5.1.62 ############################# [100%]
Assuming that after one hour you are not happy with the upgrade and require a rollback to the previous version, then do the following:
# rpm -Uvh --rollback '2 hours ago' Rollback packages (+1/-1) to Thu Jul 31 23:26:52 2003 (0x3f29ddfc): Preparing... ########################## 100%] 1:MySQL-Server-5.1.50 ########################### [ 33%]
The package will now be rolled back to the previous package and ready to run again. You only specify a point in time to roll back to rather than specifying a package. This means that all packages will be rolled back at that point, so if another package was upgraded that you want to keep at the new version, you will have to be very specific in your choice of timing for the rollback.