Speaker: Rolling back updates and patches.
So as a system administrator or system engineer,
one of your responsibility is that you need to update
your system or install patches that are vulnerable
to the system and keep your system updated.
So we often run a system updates, command yum updates
and Yum upgrades to apply those patches
to keep the system updated.
But sometimes what happen is when you do the updates
there are, or there could be some compatibility issues.
Those compatibility issues could occur
with your database or your application that you're running.
Maybe the new updates are not compatible
with the application version you're running.
So that time you need to find a way to roll back.
And in this lecture, this is what I'm going to cover.
How we could get into that problem and how we could fix it.
Now, first thing first is if you are using a virtual machine
which I think you most likely you are
and most of the corporate environment platform is now run
on virtual machine.
So the best thing and the best practice to have
a virtual machine and do the updates is that you create
a virtual machine snapshot before you apply any updates
or patches or download any packages from the repositories
or even third party vendors.
So if you have a virtual machine, what do you need to do?
You create a, you take a snapshot of the existing machine
and if something goes wrong, you could always revert back.
So that's the best option you have
if you are running a virtual machine.
Now, if you are running a physical machine, then,
of course you do not have the option to create a snapshot
and you're out of luck most of the time
and developers are testing their code,
they also rely heavily on snapshots.
And of course snapshots happen on virtual machines,
not on physical machine.
So now coming down to physical machine.
If you have a physical machine, then you're gonna have
that problem to not revert back to anything.
Then what do you do?
Well roll back a package or patch is
that you first install Yum install package name.
That's how you install a new package.
And then you could run Yum history undo followed
by the ID of that package name that was installed.
So this is mostly you would do when you have
a physical machine.
So you run a rollback on update,
meaning when you want to roll back an update instead of
just a package.
So there is one package, let's say NTP package.
You install that package, but you want to remove
that package or you updated that package.
But now you want to downgrade that update.
That is very easy to do it on one Pacific package
or one Pacific patch.
But now when you are talking about rolling back an update,
this is a huge thing because update could include hundreds
to thousand updates to your packages
that you have installed.
So based on the recommendation,
this is exactly the entire recommendation
from Red Hat or Santos or in many Linux flavors.
And that is downgrading a system to minor version.
When you do the update, for example RHEL7.1 to 7.0
it is not recommended at all as this might leave the system
in undesired or unstable state.
So if you wanted to read that statement again
please read it again, that doing the downgrade from 7.1
or 7.5 to an older version, definitely not recommended.
You could do the downgrade if you have a virtual machine.
If you have taken a snapshot,
then you could definitely go back
and revert back to the older snapshot.
That is perfectly fine.
But if you have already updated your system
and your system has an updated version,
then please I would definitely recommend it.
Do not touch it.
And at that point I would say just go ahead
and install fresh to the version that you want to have it
compatible with your application.
So if you still decided to roll back an update
or an upgrade, then here are a step.
Now there are two things that you also have to keep
in mind right here.
One is to, there are two type
of system update you have, you could do.
One is actual the update and one is the upgrade.
You could do yum, update what exactly this command do.
This command actually update
and will preserve the old updates.
Whereas Upgrade, yum upgrade will delete obsolete packages.
So when you run the Yum update,
it will keep the older packages with the system,
it's not gonna remove them.
When you run Yum upgrade,
you'll upgrade to the newer version
and it will actually remove old packages.
So then when you, if you have already ran the Yum upgrade,
then most likely you're not gonna have the option
to roll back at all at this point.
So let's see if you have done the Yum update, great.
Now what's the next step?
Next step is you will do the same thing
as if you were doing this for one Pacific package is
that you run Yum history space undo space
the ID of that Pacific task that you did.
And that Pacific task is yum update
and it will actually remove all those updates
that it has applied
and it will report back to the older version.
And of course, hopefully this works
but there is no guarantee that it will actually be
or leave the system in a stable condition.
Anyway, good luck with that.
But let's try on our Linux machine how we could go
and roll back a patch or package
and how we could roll back an update.
So before you start doing any downloads or updates
or upgrades to your system, I would recommend
you take a snapshot of your virtual machine,
if you are using a virtual machine.
My virtual environment is running
on Oracle virtual box platform.
So what I'm going to do is this is my machine
that is running.
So I'm going to take a snapshot by clicking here
and I'm gonna name the snapshot most of the time.
I name it with the date when it was taken and I click okay,
this is going to take the exact same snapshot,
the exact same, the state of the machine
that it is right now.
So if I wanted to change anything afterwards
from this point on, I could always come back to this state
by clicking here and go to revert to Snapshot to this one.
So now I have taken Snapshot.
Now let's move on to doing our package install
and let's move on to doing the our Yum update or upgrade,
whatever that we have to do.
So let me log into my Linux machine,
and I have the Linux machine right here and I will go over
each of this command to show you how you could roll back
a package or patch or you could roll back an entire update.
So I've logged in as root
and I am going to install a package
as an example in my Linux machine.
And that package I will use screen.
A screen is just a package that allows you to record session
or do certain functions on
while you are putting in to your Linux machine anyway.
So when we run this command, yum install screen,
it will go online and check for any dependency.
It found the package and it says the total download size
is 552K, installed size is 91K.
Is this okay?
You wanna go ahead and install it?
Yes. I wanted to go ahead and install it.
All right, it's going in to, it's actually going to
the repository, checking if there are dependencies.
Okay, so it says installed,
so I could verify if it has installed
by running command RPM minus QA and grep for screen.
And it came up with exactly the package
that it has installed.
This is the one, okay, so now, we have downloaded
the package perfect,
but now we wanted to downgrade or remove that package
or if the package already exists, then,
of course downgrade because it doesn't, it isn't compatible
with the application that we are running.
So at this point I will run a yum history command
and this command would tell me that the latest one,
the command that I ran is right here as root.
I ran at this time, at this date,
and I used the install and it altered one package.
So the ID is 17.
So if I wanted to downgrade or remove it, I would do Yum.
History undo and the pro-, sorry,
the the ID, the task ID.
So hit enter and it's saying that it's going to remove
this package screen, remove one package,
and then you go ahead and hit yes and now it is completed.
Now you could go ahead and RPM minus QA and grep for screen
to see if it's still there.
It is not there.
It has a genome screen
which is not exactly one that I'm looking for anyway.
So if you had an older version of the package
then it would not have removed it,
it would have downgraded it to the older version.
Okay, so now this is about a single package
or a single patch that you apply.
Now let's talk about when you perform an update
to your system, then of course as I said before,
this is not recommended and I wouldn't recommend you guys
try that unless you actually have a proper support from
Red Hat or whichever the Linux operating system
you're using.
Okay, so if I'm doing updates,
so let's run the update, yum update.
As I said, always use Yum update instead of
upgrade because upgrade will remove the obsolete
packages or delete obsolete packages, the older packages.
So you cannot roll back anymore.
So let's do yum update, hit enter.
This is going to get a list of everything
that needs to be updated.
I have a total updates that needs to be updated.
Is 159 packages. The size's there?
Is it okay?
Yes, go ahead and install.
So I hit Y and it is going through the entire list
of packages that needs to be updated.
Now at this point I am going to fast forward this
because this might take a little longer depending
on your system and depending on your ethernet
or internet speed.
Okay, so the updates have been completed.
We could verify it by running Yum history
and list or all, but for now, just put Yum history
and you'll see right up there on the top, the number 19
the task 19 is to install or update
and this the date and the time that was done.
Now if you want to undo anything like that,
I would recommend you that you take a snapshot
of your virtual machine
if you are running a virtual machine.
If you are not, then,
of course then you would have to have a support
from any enterprise level support
on the Linux platform you're running.
Okay? So as we have this list
or the history of our jump command, we notice
that the number 19 is the one that we want to undo.
So we will do the same command
as if you were doing to undo a package, yum history undo.
And the task number is number 19.
So let's run 19 here.
Okay? We are getting the downgrades total packages of 159.
You could go ahead and hit Y, it will downgrade
and remove any packages that were installed there
but I'm not going to do that.
But if you really have to do
because of the compatibility issue, go ahead and hit Y
and it will go through the entire process of downgrading
or removing and clean up a process.
So if you run into issue, the good thing is
that you do have, you do have the snapshot.
So you could always revert to that snapshot
that you take if things goes wrong.
So that's how you do the rollback.
I hope this lecture serves its purpose.
If you have any question,
please send me a message and good luck.