How can I copy data from one MySQL server to another based on a SELECT statement (then delete the data from the original)? I have a very large log table from which I want to copy rows, putting them into the same table structure on a new server.  I don't want to copy everything, only old rows, so that the table on the main server stays small-ish.  So I have to SELECT the data I want and only move (and delete) that.

Keep in mind that there is a lot of data, and I don't want to copy it all with a mysqldump if I don't need to, especially if it's going to lock the table while it's being copied.

The best I've come up with is a PHP script, which I will post as a tentative answer, although I'm certain it's not the best option.
You are looking for pt-archiver, part of the Percona Toolkit. The tool can purge rows from a table; write rows from a table to file; purge rows from a table while copying them to another table (possibly another server)...

It does so in chunks, so like 1,000 rows at a time, so that there is no high load on your server.