I regularly provide one of my clients with a backup of his data in the form of an external hard drive. Since his server runs CentOS Linux and his computer is a Windows machine, I need to provide a drive formatted Fat32 so he can plug it into his computer and access the data without problem.
# mount -t vfat /dev/sdc1 /mnt/usb -o shortname=mixed -o utf8
The “shortname=mixed” keeps the case preserved, as otherwise vfat will convert any filename that’s 8 characters or less to lower case (default behavior is “shortname=lowercase”) and cause problems for rsync. UTF8 is what Windows uses when mounting filesystems, so we specify that to ensure that we’re mounting it the same way (default is to mount iso-8859-1, even though the underlying vfat filesystem will store filenames in UTF8 format).
My normal mirror command, “rsync -az /home /mnt/usb
“, doesn’t work because -a is a shortcut for the following options:
-a, –archive archive mode; same as -rlptgoD (no -H)
-r, –recursive recurse into directories
-l, –links copy symlinks as symlinks
-p, –perms preserve permissions
-t, –times preserve times
-o, –owner preserve owner (super-user only)
-D same as –devices –specials
-g, –group preserve group
Using -o will cause errors, as rsync will copy the file and then chown (change owner) the file. Fat32 doesn’t support Unix owership or permissions, so rsycn will error on every file that is copied. Ditto for -p and -g. Symlinks aren’t supported either, and we don’t want -L to copy the destination file of the symlink (that will produce multiple copies of a file/directory, not desirable in this particular instance). The -D option is irrelevant because we are only copying website data, so we don’t need special devices (/dev/*).
That leaves -r (recursive), -t (preserve times) for our vfat options. There’s no need to use compression (-z) since we’re not syncing across the network.
So the best command to copy form ext3 to Fat32 drive is something like this:
rsync -rtv /home /mnt/usb
I like using -v for verbosity, unless I’m running this within a shell script.
A good reference for further reading on Fat32 with Linux:
http://www.osnews.com/story/9681/The_vfat_file_system_and_Linux/