Manual:ExportSites.php

Details
exportSites.php is a maintenance script that exports site definitions from the sites table to an XML file.

Common error
This error occurs when the user running the script does not have permission to write the file.
 * Failed to open $file for writing.

To resolve, check the user's permissions. If you are a root user, you can run the script with sudo.