Q:

How to list files and folders that are not maintained by any DEB package

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?

A:

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

A:

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.

