Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm a Class A Muppet. I have had /var/spool/ mounted as tmpfs for over a year and that means crontab has never been able to remember what it's doing and postfix has been broken.

I'm not asking to restore lost data. That data is long gone.

I would like to restore the default content of /var/spool/ though. crontab seems to manage to write its own but to get postfix back online I have to reconfigure (or reinstall) it. These are just two systems that I know of. There could be dozens more.

Is there any way to tick through all the installed packages and work out which should have something in /var/spool/? And by extension, is there any simple way to restore that data?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

After you've unmounted, and got rid of the configuration to mount /var/spool as tmpfs by removing it from /etc/fstab, you can run the following commands to reinstall all the packages which own files in /var/spool:

dpkg -S /var/spool | sed 's/\:.*$//;s/,//g' | xargs sudo apt-get install --reinstall

The dpkg -S command lists all of the packages which own /var/spool or something under it. The pipe to sed strips off the end and then removes the commas from the comma-and-space-separated list of package names. And finally the xargs is to pass the list of packages on to sudo apt-get install --reinstall as the list of arguments, rather than the normal STDIN that a pipe sends to.

share|improve this answer
1  
Might even be cleaner as sudo apt-get install --reinstall $(dpkg -S /var/spool | sed 's/,//g;s/\:.*$//') but I'm going to stop messing around with it for now! –  Oli May 30 '13 at 14:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.