Rollback an apt-get upgrade if something goes wrong on Debian / Ubuntu Linux
Rolling back to the previous version may solve the problem or free the disk space. Both CentOS/RHEL support rollback feature, but I learned hard way both Debian and Ubuntu does not support rollback feature yet.
Know the problem before choosing the solution
I remotely administer a Ubuntu 14.04.3 LTS server in one of those dirt cheap clouds, and I will periodically use apt-get command to install packages or do upgrades. I wanted to set up “Planet Venus” ( a flexible feed aggregator ) software on my system. For some weird reason, I ran: $ sudo apt-get -y --install-suggests install planet-venus
I should have stopped the installation. But, I was too tired and
overworked that day. The result was a disaster. I ran out of disk space,
and it installed 1764 packages on the system. My planet-venus
installation broke down too. It was one of those days where I made
mistakes and forgot to take snapshot/backups. Long story short:
I tried Google and found this wiki page not so helpful. A couple of mailing list and forum posts did not help at all. Finally, a hint come from Twitter:
Does anyone know a simple way to rollback packages on @Ubuntu Linux 14.04 LTS server?messed up.. I need to rollback over 1k+ packages
# Run as root# Store packages name in $pp="$(</tmp/final.packages.txt)"# Nuke itapt-get--purge remove $p#clears out the local repository of retrieved package filesapt-get clean# Just in case ...apt-get autoremove# Verify disk spacedf-H
# Run as root
# Store packages name in $p
p=”$(</tmp/final.packages.txt)"# Nuke it
apt-get –purge remove $p#clears out the local repository of retrieved package files
apt-get clean# Just in case …
apt-get autoremove# Verify disk space
df -H
Conclusion
To help yourself, you must be yourself. Be the best that you can be.
When you make a mistake, learn from it, pick yourself up and move on.
–Dave Pelzer
I learned that:
The best time to backup is before you do major stuff on the server.
Think twice. Hit enter once.
Never trust blindly the apt-get or any command that has -y option.
Always make the snapshot. Unfortunately, this box still uses ext4.
There is no option to set my filesystem to BTRFS/ZFS (Linux on ZFS) with
this cloud server provider. So I’m stuck with ext4 for now.
No comments:
Post a Comment