We (UMN) have multiple Moodle instances (dev, test, prod, 2.2, 2.4, archive, ...) and so far couldn't seem to find a tool to copy roles from one instance to another.
While waiting for development of a tool that properly copies data from the role_* tables, we thought that the most tedious part in the manual process is to match the capability/permission from the existing role to the new one, so we whipped up a Firefox extension to see if it can help our Moodle admins a bit.
After installing the extesion to Firefox (menu File > Open ..., select the xpi file, no restart required), when you are in add/edit role page (the URL looks like /admin/roles/define.php?action=edit&roleid=1), right-clicking in Firefox will show the context-menu with an entry "Copy Moodle role settings". After copying, another context-menu entry called "Apply Moodle role settings" will appear, allowing you to apply the copied role settings (to another role tab/window).
So, instead of copying the roles from one server to another, we go the long route by copying the role's capability/permission through the browser, from one tab to another. Note that the extension is purely in-browser, nothing changes until you hit the "Save changes" button on the add/edit role page. This extension simply read the radioboxes values from one tab and apply to the radioboxes of another tab.
I picked the generic name "moodyfox" with the plan to add more features to make Moodle easier to use with Firefox. Feedbacks are very appreciated.
Note: the extension only activates if the URL matches /.*moodle.*\/admin\/roles\/define\.php\?action=.*/, so you might not see the entry "Copy Moodle role settings" in Firefox context-menu if your server doesn't have "moodle" in its URL. Maybe I should relax that matching rule a bit?