Paul E Condon wrote at 2009-03-27 09:26 -0600: > Now, the discussion has moved to how to query the packaging system to > get the most useful file of information. I'm still not sure what the > query string should be.
Restoring the package set is not so simple as restoring the packages that are manually selected as installed. There are at least these reasons: - virtual packages or 'OR' dependencies Package 'ilohamail' depends on 'postfix | mail-transport-agent' so package 'exim4' (or another mail server) may be set as automatically installed. If a list of manually installed packages is used, aptitude may select 'postfix' instead of 'exim4' to satisfy that dependency. - 'recommends' dependencies That some package 'ilohamail' recommends 'gnupg' and 'aspell'. The user has the option of using that or not, and aptitude has a config option for it too. If the user allows 'aspell' to be installed automatically, then it may or not be installed when a list of manually installed packages is used, depending on the user of the -r or -R flags. Either way, either a package is installed automatically that was not before, or a package is not installed that was before. So, one must do backups slightly differently. Here are the commands that I use: # Save aptitude state bundle aptitude-create-state-bundle state.tar.bz2 # Save a list of all installed packages aptitude -F "%?p" --disable-columns search \~i >| installed-all # Save a list of all installed packages with their versions aptitude -F "%?p=%?V" --disable-columns search \~i >| installed-all-ver # Save a list of all automatically installed packages aptitude -F "%?p" --disable-columns search \~i\~M >| installed-auto Here are the commands I have saved for restoring from the aforementioned backups: # Install all essential, important, required, or standard packages aptitude -R --schedule-only install $( aptitude -F "%?p" search \!\~i?or(\~E,\~pimportant,\~prequired,\~pstandard) ) # Mark as manually installed all essential, important, required, or standard priority packages aptitude -R --schedule-only unmarkauto $( aptitude -F "%?p" search \~i?or(\~E,\~pimportant,\~prequired,\~pstandard) ) # Mark as automatically installed all packages that are not essential, important, required, or standard priority aptitude --schedule-only markauto $( aptitude -F "%?p" search \~i\!\~E\!\~pimportant\!\~prequired\!\~pstandard ) # Install all the packages in the installed package list (manual + automatic) aptitude -R --schedule-only install $( cat installed-all ) # Select specific versions of packages (you may want to skip this step) aptitude -R --schedule-only install $( cat installed-all-ver ) # Mark as automatically installed all packages in that list aptitude --schedule-only markauto $( cat installed-auto ) # Run aptitude, check scheduled actions, and apply aptitude I think I have minimally tested these commands, but it has been a while. It would be great if someone could try this out and add a wiki page for it. Of course, it would likely help to restore a /etc/apt backup before doing any of the restore commands. Obviously a different sources.list would cause problems. Lastly, I don't think it is possible to restore the package set perfectly if much time has passed between the backup and the restore, because of changes in package versions; the more time passes, the more the package set will have to change for a restore. This is why I have added the backup command that saves the versions for all installed packages. The only way to get around this is to have a backup of debs for ALL installed packages.
signature.asc
Description: Digital signature