I guess you could put the code in a while loop. eg. while (action_not_done) { $sftp = new Net_SFTP(); ... }
If it's timing out... could be that your timeout is set pretty low for what you're trying to do. A PHP timeout of 10 seconds for downloading a 10GB file might not be enough.
If it's not something like that then posting logs would help. Here's an example of how to get them: