Paul Wise wrote: > Yes, I have a backup of these directories: > > /var/lib/aptitude > /var/lib/dpkg > /var/lib/apt > /var/cache/apt > /var/cache/debconf Excellent! You should be able to fully recover. > Sorry, should have been more specific when I said "I had > a backup of my apt and dpkg state directories". No worries. I am very happy to hear that /var was backed up. Because many times it is not. But since you have it then you have everything you need. I do not have a completely canned recipe for recovery. But I think between you, me and the rest of the mailing list that we can develop one. It will be a team effort. :-) Let me think this out on the fly. So caution that it isn't fully thought out. First, I would install a minimum system. Or if not then I would install the system using the same options that you installed the original system you want to recover. The same is good. Or less is good. More package can be problematic. The problem is that you want the new system to have the same uid:gid numbers for the new system as the old system. Many packages create users when they are installed. So what you want to do is to wedge in between when the system is minimally installed and when everything else is installed and plant your old password file there first. That is why a minimum installation is usually best. If you have already installed many things then some additional users will have been installed already. Depending upon the order the uid:gid numbers will be different. That isn't terrible. But it does mean that you will need to merge the uid numbers together. * Start with a minimal system. Then replace these files with your backup versions. (Or if you didn't start with a minimal system then you must merge your backup copy into the new file. Your choice.) + /etc/passwd + /etc/group + /etc/shadow + /etc/gshadow * Restore whatever of /etc that you desire. Of course this includes the /etc/passwd files above but if you needed to merge the password files then I wanted to call it out explicitly. All of the rest could be restored directly. * Restore the debconf database. This way the previous choices made will be preseeded into the new installation. + /var/cache/debconf/config.dat * Restore the /var/lib/apt/extended_states file. + /var/lib/apt/extended_states * Use the APT extended_states file to install upon the new system. This is a file that keeps track of what you installed manually and what was installed as an "automatic" dependency. Anything with the Auto-Installed field being a "0" was installed explicitly. Anything with a "1" there was installed automatically. Install all of the explicitly installed things again. Forcing "confold" here so that the files in /etc that were restored from the previous system will be preferred. # apt-get -o DPkg::Options::=--force-confold install $(grep-dctrl -sPackage -n -FAuto-Installed 0 /var/lib/apt/extended_states) * Clean up the lint from the new config files that we just brought in. # find /etc \( -name '*.dpkg-*' -o -name '*.ucf-*' \) | less Review the above output. If looks okay then remove them. # find /etc \( -name '*.dpkg-*' -o -name '*.ucf-*' \) -delete * Restore these files from the backup. + /root + /home + /usr/local + /var/spool/cron/atjobs + /var/spool/cron/crontabs + /var/www == You are now finished with the easy stuff. What is left is also quite easy but needs some thought. == * Restore any /var/lib directories that remain from the backup. This usually entails shutting down the associated daemon first, doing the restore, then starting the daemon again. For example if mysql is being updated then stop the mysql daemon. Then restore from backup the /var/lib/mysql directory. Then restart the daemon. Test that the result is reasonable and correct. If you cannot restore from /var/lib/mysql then hopefully you will have a more explicit backup of the database. If so then if one fails you can restore from the other. * Restore any other /var/* directories that you wish to restore. For example if there were any particular logs that you wanted to preserve then I would restore those log files too. For example I would definitely want to preserve /var/log/apache and migrate it forward to the new machine to allow web log analysis tools to continue the history. At this point I believe you should be up and running with a new system that has replicated everything that was on your old system. However I did not test the above recipe. I typed that in off the top of my head. I have almost certainly created an error along the way. Please proceed cautiously and take notes and update anything that was incorrect. I also welcome any comments from other readers on the mailing list concerning this procedure. Bob
Attachment:
signature.asc
Description: Digital signature