Exclude mounted folders from tar archive

we want to backup our server and this seems to be pretty simple thing to do except one. Currently we use something like this:

tar cvpjf backup.tar.bz2 --exclude=/proc --exclude=/lost+found --exclude=/backup.tar.bz2 --exclude=/mnt --exclude=/sys /

Everything is fine, but we do not want to include mount points, as several ftp users has chrooted access to their homes with mounts like:

mount --bind /var/www/folder /home/user/html

Is the any way to exclude such folders from being backuped?


Solution 1:

Use the appropriate tar command line option:

       --one-file-system
              stay in local file system when creating archive

Solution 2:

The option --one-file-system does work, it just needs some very specific syntax.

tar -cvzf /mnt/backup.tar.gz --one-file-system /

works, but

tar --one-file-system -cvzf /mnt/backup.tar.gz /*

does not. This is probably because shell globbing will result in the option being applied to each and every subdirectory of / individually. So /proc gets included because everything in /proc is indeed one file system.