Pulling 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
happens 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 are running. So that time,
you need to find a way to rollback. 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 will 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 from the repositories or even third
party vendors. So if you have a virtual
machine, what do you need to do? You
create, you take a snapshot of the
existing machine. And if something goes
wrong, you can 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 when developers
are testing their code, they also rely
heavily on snapshots. And of course,
snapshots happen on virtual machines not
in physical machine. So now coming down
to physical machine. If you have a
physical machine, then you're going to
have that problem to not revert back to
anything, then what do you do? Well
rollback a package or patch is that you
first install yum install package
name. That's how you install a new
package. And then you can run yum
history undo followed by the ID of that
package name that was installed. So this
is mostly you will do when you have a
physical machine. So you run a rollback
on update. Meaning when you want to rollback an
update instead of just a
package. So there is one package, let's
say NTP package, you install that
package, but you wanted 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
specific package or one specific patch.
But now when you are talking about
rolling back an update, this is a huge
thing because update could include
100s to 1000s updates to your packages
that you have installed. So based on the
recommendation, this is exactly the
entire recommendation from Redhat or
CentOS or in many Linux flavors. And
that is, downgrading a system to minor
version. When you do the update, for
example, RHEL 7.1 to 7.0, it is
not recommended at all, as this might
leave the system in undesired or
unstable state. So if you want to read
this 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 oldest
snapshot, that is perfectly fine. But if
you have already updated your system and
your system has 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 decide to
rollback, 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, there are two type
of system update you could do. One
is actual 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 is not
going to remove them. When you run yum
upgrade, you will upgrade to the newer
version, and it will actually remove old
packages. So then if you have
already ran the yum upgrade, then most
likely, you're not going to have the
option to rollback 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
specific package, is that you run yum
history space, undo space, the ID of
that specific task that you did. And that
specific task is yum update. And it will
actually remove all those updates that
it has applied, and it will revert 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 the stable
condition. Anyway, good luck with that.
But let's try on a Linux machine how we
could go and rollback a patch or package
and how we can rollback 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
VirtualBox 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 going to name
the snapshot, most of the time I name it
with the date when it was taken, and I
click OK. 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 our yum update or upgrade
whatever that we have to do. So let me
log into my Linux machine, I have the
Linux machine right here, and I will go
over each of this command to show you
how you can rollback a package or
patch or you can rollback an entire
update. So I'm 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, into 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 sizes
91k. Is this okay? Do want to go
ahead install it? Yes, I want to go ahead install it.
[No audio]
All right. It's going in to, is actually
going to the repository checking if
there are any dependencies. Okay, so it
says installed. So I could verify if it
has installed by running command rpm
-qa and grep for screen.
[No audio]
And it came up with exactly the the
package that it has installed, this is the
one. Okay so now, now we we have
downloaded the package, perfect, but now
we want it to downgrade or remove their
package. Or if the package already
exists then of course downgrade because
it doesn't, it isn't compatible with the
application that we're 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 to install,
and it altered one package. So the ID is
17. So if I want to downgrade or remove
it I would do yum history undo and
prosper sorry, the ID that 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 -qa, and grep for screen to see
if it still there. It is not there, it
has a gnome-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, when you perform an update to
your system. Then of course, as I said
before, this is not recommended, I
wouldn't recommend you guys try that
unless you actually have a proper
support from Redhat or whichever the
Linux operating system you're using.
Okay, so if I'm doing updates, or 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 rollback 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 and
needs to be updated is 159 packages, the
sizes 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.
[No audio]
Okay, so the updates have been
completed, we could verify it by running
yum history, and lists are all but for
now just put yum history and you'll see
right up there on the top number 19. The
task 19 is to install or update. And
this is the date and it's time that was
done. Now, if you want to undo anything
like that, I will 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 will
have to have a support from many
enterprise level support in the Linux
platform you're running. Okay, so as we
have this list or the history of our
yum command, you 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.
[No audio]
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 cleanup
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 this purpose. If you have any
question please send me a message and good luck.