Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am in the process of moving my files from one Debian machine to another so that I can use the old machine for a different purpose. I do not want to miss any file because I will be formatting the old machine's hard drive irrecoverably.

Thinking about this more, I realized that all of the files and folders that I need to copy are the ones that are not maintained by any installed Debian package. Is there a simple way to list such files and folders?

share|improve this question
add comment

2 Answers

up vote 10 down vote accepted

cruft is a useful tool exactly for this purpose: it makes a comparison between a file system and the database of installed Debian packages. In addition to listing unknown files it also lists files which are missing but should be there.

I use it routinely together with debsums when I need to start system administration or upgrade work on machine which I did not take care of earlier. This allows me to spot any local modifications and installations and plan for them, instead of the customer telling me after an upgrade that their software does not work any more.

Install:

apt-get install cruft

List all "cruft" but ignore the named directories:

cruft --ignore "/dev /proc /sys /root /home /tmp"

More information:

man cruft
zless /usr/share/doc/cruft/README.gz
share|improve this answer
    
Perfect! Thank you. –  Daniel Trebbien Aug 4 '11 at 18:25
add comment

If you haven't done anything unusual, then the answer is that everything in /bin, /boot, /lib*, /sbin and /usr come from Debian packages, except that /usr/local is yours; the rest of the system is yours. The typical locations you would need to back up are /home and /etc (always), /var (most of it; for example /var/cache doesn't need to be backed up), /srv (if you use it), and /usr/local and possibly /opt.

To list the regular files on the / filesystem that do not come from Debian packages:

find / -xdev -type f | sort >/tmp/root.list
sort /var/lib/dpkg/info/*.list >/tmp/dpkg.list
comm -23 /tmp/root.list /tmp/dpkg.list

If you have a separate filesystem for /usr, include it in the find command. If you have a separate filesystem for /home or /var or other custom location, include it in your backup.

share|improve this answer
add comment

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.