Sunday, August 31, 2008

VMware in Ubuntu: Backing Up and Restoring

I had been working on completing my VMware installation, detailed in a series of posts, when I made such a hash of multiple monitor installation in Ubuntu (version 8.04, Hardy Heron) that I decided to give up and start over. A kind soul had responded to a question I posted by telling me a few things to help with the start-over process, so that's where this new post begins. My basic setup: 64-bit Ubuntu with dual monitors, installed on each of two computers, both of which were dual-boot setups with Windows XP as the alternative. I used the WinXP installation on my primary computer as the starting point for VMware Workstation 6: that is, I used VMware Converter to create a basic WinXP virtual machine from that native WinXP installation, and then I used Workstation to run and add more programs and adjustments to that basic WinXP VM. So at this point, I had several VMs for different purposes. As I contemplated the project of restoring my Ubuntu setup, possibly from scratch, I was pleased to have those VMs, because I expected those virtual machines to survive and run just fine. That is, unlike Windows, I would not have to reinstall those particular programs; I would just have to reinstall VMware Workstation. I would have to reinstall Workstation, that is, if my first line of defense failed. I had bought a copy of Acronis True Image and had made a backup, but had never before tried to restore from a True Image backup. Acronis was supposed to be able to back up and restore Linux as well as Windows partitions. My Acronis backup was two weeks old at this point, but that was OK; during maybe half of those past two weeks I hadn't been doing much tinkering with the system, and for the other half I had some notes. I was a little concerned about using True Image because someone had said, somewhere, that it wipes out all of the partitions on a drive when you use it to restore one partition. I thought that was probably a case of user error, but it was not the kind of thing I wanted to learn from experience. Fortunately, the other main partition on that drive was a backup partition, so I just made sure I had alternate copies of whatever was there. In case the Acronis True Image restore process failed, I followed the advice mentioned above. First, I made a backup of my /etc and /home folders. They said to use a backup program, so I used sbackup, which I had previously installed using Ubuntu's System > Administration > Synaptic Package Manager. Sbackup had created a shortcut in System > Administration > Simple Backup Config. I saw that it had somehow gotten configured to include /var and /usr/local along with the other two folders just mentioned, so I went with that. I clicked Save and told it to run the backup now, and it told me it was doing it in the background. I went off to do something else, and when I returned, it had created a file called Files.tgz of over 300MB. I highlighted those four folders in File Browser and right-clicked for their Properties, and it said they were about 1GB. So I couldn't tell whether they were capable of being compressed that much, or if maybe Sbackup had missed some. I tried opening the flist file that Sbackup had created, thinking it would be a file list, but Ubuntu said it didn't know of a program to open it with. I opened the files.tgz file and saw that it claimed to contain about 670MB of files. Just in case, I also tried to do a straight-across (uncompressed) copy of all of the Ubuntu folders except /media. I checked the Properties of each, and the only one much over 1GB was /proc. But the copy process (a) notified me that it couldn't copy the "ray" folder even though I was running as root, and (b) seemed to freeze after copying 24.3MB, making me wonder whether the existence of multiple copies of system files could confuse Ubuntu as a similar maneuver could confuse Windows. I couldn't think of another way to do a better backup, so I left it at that. The response to my question also suggested running this command: "dpkg --get-selections >installed-packages.txt." They pointed me toward another thread that explained how to use this to reinstall the packages I had installed to date. So I ran that and saved the resulting installed-packages.txt file to another drive. I looked at it and, wow, it listed hundreds of packages. Probably most of them had been installed automatically with Ubuntu, but still -- it looked like an impressive and possibly very useful tool, this dpkg thing. So the time had come to take the leap. No doubt I was forgetting something that would cost me hours of additional work, but I didn't know what else I could do in preparation, and time was marching on. I rebooted the primary computer with the Acronis CD, all the while making notes here on the secondary computer. I was a little nervous, so I started with a look at their help file, which -- to my surprise -- recommended trying to restore data first by running True Image within Windows. This was just the opposite of Drive Image 2002, which I had been using for some years. Drive Image had been much more effective running from the CD. Since this was a test of Acronis as well as an attempt to get my Ubuntu installation back, I decided to start with the CD, which I would use in the worst-case scenario (i.e., if Windows wouldn't run). I chose the Recovery option and pointed it toward the .tib file containing my True Image backup of the Ubuntu program partition. I selected "Restore disks or partitions" and chose to restore only the partition itself, not the MBR (Master Boot Record). I told it to restore to the Ubuntu partition, which it was calling drive H in Windows-speak. This was a little disconcerting because True Image was not reporting drive labels for any ext3 partitions, and I had several of them at this point. I had tried to label all of my partitions, but maybe GPartEd had failed to label them; I couldn't remember for sure. The backup was the same size as one of the available ext3 partitions, however, and I had already scoped it out in Windows, so I was pretty confident I knew which ext3 partition I wanted to wipe out and replace with the backup -- even though the drive letter saved in the backup no longer matched the one I was planning to wipe out. Finally, I told it to validate the backup archive before restoration. I had already validated it after creating it, but I hated to wipe out a live Ubuntu partition for the sake of a dead backup, just in case something had affected that backup file in the past two weeks. I was impressed with all the careful questions True Image was asking me; there wasn't nearly as much of a plunging-off-a-cliff feeling as there had been in Drive Image. After a few minutes, it said, "The data was successfully restored." So I thought, OK, we'll see. I took out the CD and rebooted the computer. Ubuntu acted like it was starting up -- GRUB ran, and then I got "Ubuntu" on a black screen with an orange slider indicating startup progress, so all was well -- and then, suddenly, "No signal" appeared on my monitor, and the computer was still. Not the desired outcome! I waited a minute or two. Nothing further. I punched the computer's reset button. This time, I chose GRUB's Recovery Mode for Ubuntu. In the Recovery Menu, I ran dpkg ("Repair broken packages") and xfix ("Try to fix X server"). Then I selected "Resume normal boot." This time, I got to the Ubuntu sign-in screen. And, just like that, I had Ubuntu back. Right away, it needed a restart to complete its update of something or other. But it seemed to freeze at "System is restarting, please wait . . ." After about ten minutes, I tried hitting Enter, Esc, Ctrl-Alt-Del. No action. Hard drive light was off. So I punched reset. One again, we went through login and I had a normal-looking Ubuntu desktop. I started up Firefox and Workstation. Firefox showed me that the first thing I had forgotten to think about was the location of the backup files for Session Manager, the add-on that remembered what webpages I had open. I wasn't sure where Session Manager had been saving those. It was supposed to have been saving them on another partition, but they didn't seem to be there. So I had to fix that and bid goodbye to those webpages I had opened in Firefox during the past two weeks, had not yet read and closed out, and couldn't presently remember. There seemed to be no question, at this point, that the Acronis backup strategy worked, and that I would ideally have used it instead of screwing around for hours on the previous day in my vain attempt to get the Ubuntu multimonitor resolution right. Next time around, I would try to remember to run Acronis before getting into the multiple monitor thing, so if it went bad again, I would be back in business within the hour. I still had to reinstall some other things that I had previously installed. The description of that process appears in a new post.

0 comments: