You need to find out what user PHP is running as...this can vary depending on how your script gets run. If you access this script via a web server, i has the same permissions as the web server. If you run it from the command line, it runs as whatever user you are logged in as. If it run as a cron job, that can be an entirely different user. The easy way to find out is to trigger the script however it gets triggered and do this command:
passthru('whoami');
NOTE: if the script is run as a cron job, [man]passthru[/man] may not be all that useful because you don't necessarily know where the output of the script does. It all depends on how you set up the cron job.
Once you know who the user is, you have to assign write permissions to the directory where the file is supposed to be written. You can either click around in the mac os and try to do it through whatever GUI they have (sorry don't know much about this) or you can do it from a terminal window with the chown and chmod commands. Suppose your 'whoami' command returns 'sneakyimp':
chown sneakyimp:sneakyimp /Volumes/my_usb_hd_name
chmod 775 /Volumes/my_usb_hd_name
The first command changes ownership of your backup drive, the second command sets the backup drive as readable/writeable/executable for the owner and group of the backup drive and readable/executable by everyone. you could try 770 if you are concerned about giving too much access to the world.
EDIT: It's been my experience that on a mac you have to put 'sudo' before commands to change ownership...this will result in a prompt for you to enter your root/administrator password for the machine:
sudo chown sneakyimp:sneakyimp /Volumes/my_usb_hd_name