Copying a binary and it's shared libraries to a chrooted directory

Today, I needed to construct a command for copying the rsync binary and it's library dependencies to a chrooted directory. Since this might come in handy in the future, and might help other people to achieve the same as well, I decided to post it on here.

cp /usr/bin/rsync /var/www/vhosts/;\\
ldd /usr/bin/rsync|awk '{print $3}'|grep -e '^/'|xargs -I{} cp -v --parent '{}' /var/www/vhosts/

A quick breakdown. At first, we just do a plain copy of the rsync binary. After that, we fire up ldd on the rsync binary, then use awk to only return the third word of each output line of ldd (which should be the location to the binary). To make sure it's a full path, a grep -e on that result should make sure the output starts with a slash (if ldd returns only a name rather than a full path, the binary will probably not work in the chrooted environment, so this method is not 100% fool-proof). Finally, we copy the matches into our chrooted environment using the --parent option (and -v for verbosity so you can see what is actually copied), so that the paths are entirely copied, e.g.: /lib64/ would become /var/www/vhosts/ Rather than putting it hardcoded into /lib or /usr/lib, the --parent option adopts the relative path the library should have within the chrooted environment.

In my case, this command worked perfectly for getting rsync to run. But again, it might not be 100% fool-proof for everything. Any additions/suggestions to make it so are welcome.