Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
System Rollback Capability
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gentoo Chat
View previous topic :: View next topic  
Author Message
ashari
n00b
n00b


Joined: 09 Sep 2002
Posts: 10

PostPosted: Sun Dec 22, 2002 12:01 am    Post subject: System Rollback Capability Reply with quote

The system should be able to be taken back to a specific point in time, which was previously "recorded".

command: emerge --record rollback
output: Rollback recording initiated...
output: Rollback point named "20021221_2.rollback" created.
output: Rollback recording complete.

command: emerge --play rollback
output: Choose a rollback point:
output: 1) 20021221_1.rollback
output: 2) 20021221_2.rollback
prompt: #>

The user would then select "1" or "2" and the rollback would occur -- downgrading (or upgrading) packages as needed to match exactly what was installed at the specific time of recording the selected rollback point.

The problem that I can see right now is that of home dir configuration files. For instance, if you currently have KDE3.1 installed, and rolled back to when you had KDE2.1 installed, there would probably be a problem when trying to run KDE. Obviously this cannot be helped, unless config files in the home directories were also stored in the rollback, which could be very tedious. This is probably left up to the user, or maybe someone has a better idea?

Peace.
Back to top
View user's profile Send private message
Techie2000
Guru
Guru


Joined: 16 May 2002
Posts: 344

PostPosted: Sun Dec 22, 2002 2:32 am    Post subject: Reply with quote

So basically what your looking at is taking a snapshot of /var/db/world and recompiling the system?
_________________
"And I'm right. I'm always right, but in this case I'm just a bit more right than I usually am." - Linus Torvalds
Back to top
View user's profile Send private message
ashari
n00b
n00b


Joined: 09 Sep 2002
Posts: 10

PostPosted: Sun Dec 22, 2002 3:34 am    Post subject: Reply with quote

Techie2000 wrote:
So basically what your looking at is taking a snapshot of /var/db/world and recompiling the system?


Thank you for the reply and question.

I do not have the experience to give exact details, just some ideas on what would be a great feature to implement.

I envision that "emerge --record rollback" would take a snapshot of the system, maybe run "qpkg -I -v" (from the gentoolkit package) and capture the output, then store it in the rollback file, along with any other pertinent information. The idea would be not to go too overboard, like trying to check what "was" installed against masked packages or anything like that... just take a snapshot of what was installed, then bring the system back to that point without much fuss.. just remove whatever "future" package was installed and recompile the old version, in a sane order (emerge probably already takes care of that stuff anyways).
Back to top
View user's profile Send private message
vericgar
Retired Dev
Retired Dev


Joined: 13 Dec 2002
Posts: 79
Location: Spokane, WA

PostPosted: Mon Dec 23, 2002 12:17 am    Post subject: Reply with quote

No guarantee of how well this will work, but it should... I whipped this up in only a few hours, and it's been tested for functionality, but not extensively... please let me know what should be changed in it... and whether other things should have a snapshot taken of them (USE variables maybe? dont know)

Code:

#!/bin/bash
#
# portback
# Simple Utility to rollback a gentoo system to a certain date
# Copyright 2002 Michael Stewart
# Released under the GPL Version 2

# This works by generating a world file of the snapshot date and when it comes
# time to rollback it copies the rollback information to the world file (of
# course backing up the current world file) and then does a emerge -u world

# NOTE: This should be added to the crontab on install so that it generates
# the snapshot on a regular basis.

# This assumes the following:
# - qpkg 0.1.17 is installed (other versions may or may not work)
# - portage-2.0.46-r2 is installed (other versions may or may not work)
# - the portage tree (/usr/portage) still contains the ebuilds for the rollback

### Configuration

# Directory to store the portback files
PBDIR=/var/db/portback

# Location of the world file
WORLD=/var/cache/edb/world

### End Config

case "$1" in
        generate)
                if [ -z "$2" ]; then
                        NAME=`date +%Y%m%d`
                        echo "No snapshot name specified, using $NAME"
                else
                        NAME="$2"
                fi
                if [ -e "$PBDIR/$NAME.portback" ]; then
                        echo "Snapshot $NAME already exists!";
                        exit;
                fi
                echo "Generating snapshot: '$NAME'"
                mkdir -p $PBDIR;
                qpkg -I -v -nc | sed 's/.*/=&/' > $PBDIR/$NAME.portback
                cp $WORLD $PBDIR/$NAME.world
                echo "Snapshot saved!";
                exit
    ;;
        quiet)
                if [ -z "$2" ]; then
                        NAME=`date +%Y%m%d`
                else
                        NAME="$2"
                fi
                if [ -e "$PBDIR/$NAME.portback" ]; then
                        exit;
                fi
                mkdir -p $PBDIR;
                qpkg -I -v -nc | sed 's/.*/=&/' > $PBDIR/$NAME.portback
                cp $WORLD $PBDIR/$NAME.world
                exit
        ;;
        pretend)
                if [ -z "$2" ]; then
                        echo "You must specify which snapshot to rollback to!"
                        echo "Listing system snapshots: ($PBDIR)"
                        ls $PBDIR
                        exit
                else
                        NAME="$2"
                fi
                if [ ! -e "$PBDIR/$NAME" ]; then
                        echo "Snapshot $NAME does not exist!"
                        echo "Listing system snapshots: ($PBDIR)"
                        ls $PBDIR
                        exit
                fi
                DATE=`date +%Y%m%d`
                cp $WORLD $PBDIR/world.$DATE &&
                cp $PBDIR/$NAME.portback $WORLD
                emerge -p world
                mv $PBDIR/world.$DATE $WORLD
                exit
        ;;     
        rollback)
                if [ -z "$2" ]; then
                        echo "You must specify which snapshot to rollback to!"
                        echo "Listing system snapshots: ($PBDIR)"
                        ls $PBDIR
                        exit
                else
                        NAME="$2"
                fi
                if [ ! -e "$PBDIR/$NAME" ]; then
                        echo "Snapshot $NAME does not exist!"
                        echo "Listing system snapshots: ($PBDIR)"
                        ls $PBDIR
                        exit
                fi
                echo "Rolling back system to $NAME..."
                DATE=`date +%Y%m%d`
                cp $WORLD $PBDIR/world.$DATE &&
                cp $PBDIR/$NAME.portback $WORLD
                emerge world
                cp $PBDIR/$NAME.world $WORLD
                echo "System rolled back."
                exit
        ;;     
        *)
                echo "Usage: portback mode [name]"
                echo "Simple Utility to rollback a gentoo system to a certain date"
                echo "Copyright 2002 Michael Stewart"
                echo "Released under the GPL Version 2"
                echo
                echo "  where mode is one of the following:"
                echo "    help      print this screen"
                echo "    generate  generate rollback file, uses name as the file name,"
                echo "              otherwise uses the current date as the file name"
                echo "    quiet     same as generate, but no output"
                echo "    rollback  rolls the system back to snapshot 'name'"
                echo "    pretend   lists what will happen if the rollback command is used"
                echo
                exit
esac

_________________
+~+ Sometimes a good ole loving kick is all it needs +~+
Back to top
View user's profile Send private message
oniq
Guru
Guru


Joined: 02 Sep 2002
Posts: 597
Location: Connecticut

PostPosted: Mon Dec 23, 2002 12:41 am    Post subject: Reply with quote

Stolen from XP, but a very good idea indeed. You mess up your system in some way, maybe you can't even boot into it. You boot off of your liveCD, enter your system, and portback a few dates.
_________________
open like a child's mind.
Back to top
View user's profile Send private message
Mnemia
Guru
Guru


Joined: 17 May 2002
Posts: 476

PostPosted: Mon Dec 23, 2002 3:22 am    Post subject: Reply with quote

I was never a fan of this feature on XP, at least the way XP implements it. It's usually the first feature I turn off if I'm setting up a new windows box. I'm nervous about "rolling back" a system mainly because I want to be in complete control of what it does. I'd rather fix a problem myself than allow the system to do it for me in a way I can't control. This would be good if it could tell you exactly what the changes it will make will be, and give you the option to not continue or only rollback certain things, etc. Also the way XP does this consumes large amounts of disk space and slows down the system greatly. If it's just a snapshot of the system state with a rebuild that's fine and could be useful, but if it's an actual binary/filesystem rollback I'd vote against it.
Back to top
View user's profile Send private message
pilla
Bodhisattva
Bodhisattva


Joined: 07 Aug 2002
Posts: 7729
Location: Underworld

PostPosted: Mon Dec 23, 2002 3:44 am    Post subject: Reply with quote

Well, another day I used a LiveCD to log in in a dead XP to copy some data. The rollback was to reinstall it 8)

oniq wrote:
Stolen from XP, but a very good idea indeed. You mess up your system in some way, maybe you can't even boot into it. You boot off of your liveCD, enter your system, and portback a few dates.
Back to top
View user's profile Send private message
ebrostig
Bodhisattva
Bodhisattva


Joined: 20 Jul 2002
Posts: 3152
Location: Orlando, Fl

PostPosted: Tue Dec 24, 2002 11:21 pm    Post subject: Reply with quote

Rollback is a feature used heavily in the database world.

The question here is really what you need rolled back. Is it changes done to packages, i.e new version 1.2 didn't work, need to go back to 1.1? If so, the Portage system can handle that without any changes, just emerge the correct version.

If you really wanna be able to, in a fast manner, restore data (programs and various other files), you need a different system, i.e a binary backup storage somwhere.

I don't understand the need for this change as it it really is working today.

If you for some reason can't boot your box with a kernel version, and that is your ONLY kernel version, it is not a system problem but an admin issue. Bad planning on your side does not constitute a crisis on my side! I always keep at least one good kernel configured so I always can boot into the PC. If you have a filesystem issue, LiveCD is the only good rescue. Of course, you need to back up your private data if you want to be able to keep it.

I don't see any need for implementing a rollback feature as it already exists.

Erik
_________________
'Yes, Firefox is indeed greater than women. Can women block pops up for you? No. Can Firefox show you naked women? Yes.'
Back to top
View user's profile Send private message
mmealman
Guru
Guru


Joined: 02 Nov 2002
Posts: 348
Location: Florida

PostPosted: Wed Dec 25, 2002 5:00 am    Post subject: Reply with quote

Example situation:

Last night I was playing with ntp when all of a sudden the script /etc/init.d/ntpd wasn't responding. In fact, none of the scripts under init.d were responding.

I reboot and the rc command is fubared. A script it depended on got hosed some how and none of my system start scripts would now run. This is about as f'd up as a system gets.

But it was really just a matter of booting off the live cd and re-emerging baselayout(once I used qpkg to figure out where rc came from) to fix this problem.

A rollback feature would've also done the trick, but really that's what I did manually and I learned a lot more about my system's run control layout in the process.
Back to top
View user's profile Send private message
ashari
n00b
n00b


Joined: 09 Sep 2002
Posts: 10

PostPosted: Thu Dec 26, 2002 8:08 pm    Post subject: What started this post Reply with quote

Last week I ran "emerge rsync;emerge -u world" and ended up with a fubar'd system. I have "testing" turned on, so I have no reason to complain, and I'm not complaining. What I'm doing is advocating the implementation of a widely known technique in the database world (in which I live during my day job) -- transactions. "begin transaction ... do some stuff ... rollback or commit". Problem is, in the "real world" of Gentoo using, you can't do it all in one fell swoop -- because the "do some stuff" might take a couple of days before you realize something went wrong. This started me thinking about creating the rollback points, and here we are. One of the previous posts mentioned that MickeySoft has implemented this in XP (if in a half assed way, which is to be expected).. well, I guess someone over there works with databases too ;-)

I hope this explanation was good enough to prove the point that we need this. I really don't want to have to reinstall everything, which I will most likely need to do now that my system is screwed :(

I just thought it would be nice to "rollback" a week or so, before I commited to updating my system. As it sits, I'm waiting a few more days, and hopefully all will "right itself".. but I'm quickly losing hope.

Regards,
Ashari
Back to top
View user's profile Send private message
Mnemia
Guru
Guru


Joined: 17 May 2002
Posts: 476

PostPosted: Thu Dec 26, 2002 9:42 pm    Post subject: Reply with quote

Much as it would be nice to have it magically fix major screwups like this, I'm not sure the database analogy really translates fully. A system is much more than just data; it's a big complex set of interacting components and configurations as well as data. When you have transactions in a database, you can isolate what is going on and then rollback that specific thing. But in a complete system I'm not sure that you can easily look at things in such a fine grained way. Portage as it is implemented now would probably have to be reworked in a fairly major way to add enough functionality to give good control over what is being rolled back.

Perhaps with an SQL like file system this would be more desirable and easier to add in; I think it's something we should keep in mind for the future when Linux gains a filesystem like that (ReiserFS 4? Don't know much about it).

Also, I'd note that in a way Portage already has this sort of thing. When packages are built they go into a seperate source tree that is then "merged" into the root filesystem after the compile succeeds. This is basically a rudimentary transaction system for compiles. But if the errors/messups are occurring during the merge phase when the new software interacts with the old I think Portage will have a difficult time rolling that back without some sort of database file system as I mentioned earlier. I'd also note that this is the direction MS is going with Windows - and this is probably a major reason why.
Back to top
View user's profile Send private message
ebrostig
Bodhisattva
Bodhisattva


Joined: 20 Jul 2002
Posts: 3152
Location: Orlando, Fl

PostPosted: Thu Dec 26, 2002 9:52 pm    Post subject: Re: What started this post Reply with quote

ashari wrote:
Last week I ran "emerge rsync;emerge -u world" and ended up with a fubar'd system. I have "testing" turned on, so I have no reason to complain, and I'm not complaining. What I'm doing is advocating the implementation of a widely known technique in the database world (in which I live during my day job) -- transactions. "begin transaction ... do some stuff ... rollback or commit". Problem is, in the "real world" of Gentoo using, you can't do it all in one fell swoop -- because the "do some stuff" might take a couple of days before you realize something went wrong. This started me thinking about creating the rollback points, and here we are. One of the previous posts mentioned that MickeySoft has implemented this in XP (if in a half assed way, which is to be expected).. well, I guess someone over there works with databases too ;-)

I hope this explanation was good enough to prove the point that we need this. I really don't want to have to reinstall everything, which I will most likely need to do now that my system is screwed :(

I just thought it would be nice to "rollback" a week or so, before I commited to updating my system. As it sits, I'm waiting a few more days, and hopefully all will "right itself".. but I'm quickly losing hope.

Regards,
Ashari


Well, I have only one word for you (the same word I use for our database customers calling in and crying for us to save their behinds):
BACKUP

Implement a backup schema, automate it and test the ability to restore.

If your system is so important that you can not afford to get it screwed up when you mess around trying to install new stuff, there are 2 options avilable for you:
1) Do this on a test system
2) Don't install new stuff that you are not sure if it will break your existing installation.

I have 2 PC's at work, one is my production PC (I'm very conservative on this one) and my test PC (runs all kinds of crap and I sometimes have perform 'magic' to get it to work)

Another issue with savepoints and rollback is:
What to save and where and how often?

Either you save the complete system state or nothing. Anything in between will sooner or later result in a catastrophy anyway because the file that was not saved, is the one that got corrupted.

If anyone can come up with a smart idea in between that actually works, I'm all for it.

Erik
_________________
'Yes, Firefox is indeed greater than women. Can women block pops up for you? No. Can Firefox show you naked women? Yes.'
Back to top
View user's profile Send private message
ashari
n00b
n00b


Joined: 09 Sep 2002
Posts: 10

PostPosted: Mon Dec 30, 2002 2:07 pm    Post subject: This should be checked and tested, may work? Reply with quote

vericgar wrote:
No guarantee of how well this will work, but it should... I whipped this up in only a few hours, and it's been tested for functionality, but not extensively... please let me know what should be changed in it... and whether other things should have a snapshot taken of them (USE variables maybe? dont know)


This looks pretty cool -- perhaps one of the Gentoo developers could take a look at it and let us all know how well it would work?

Thanks for replying, the nay sayers might have to eat their words if this works :D
Back to top
View user's profile Send private message
ebrostig
Bodhisattva
Bodhisattva


Joined: 20 Jul 2002
Posts: 3152
Location: Orlando, Fl

PostPosted: Mon Dec 30, 2002 10:37 pm    Post subject: Reply with quote

I looked at the suggested portback routine and I have also been running it to see what it does.

This is form of rollback that may involve a lot of time to get the system back to a known savepoint. I guess it is the best that can be done at this level.

One thing that is not accounted for is user configuration files. When you for instance downgrade to a previous version, a lot of the configuration files changes (or they very often do) and this is not handled. Very often that would involve a total reconfig the application.

So bottom lines is: A nice quick way to get back to earlier working versions of the system, but not a substitue for a decent backup.

Erik
_________________
'Yes, Firefox is indeed greater than women. Can women block pops up for you? No. Can Firefox show you naked women? Yes.'
Back to top
View user's profile Send private message
vericgar
Retired Dev
Retired Dev


Joined: 13 Dec 2002
Posts: 79
Location: Spokane, WA

PostPosted: Fri Jan 17, 2003 12:12 am    Post subject: Reply with quote

wow forgot about this thread... anyway....

about the user's config files... anything in /home I would say would be the responsibility of system backups... but for the system rollback, maybe taking a snapshot into a tar.gz of everything that's in the CONFIG_PROTECT would work? though this could start to use a lot fo disk space for system snapshots and is bordering on the fine line between snapshots/rollbacks and backups...
_________________
+~+ Sometimes a good ole loving kick is all it needs +~+
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gentoo Chat All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum