Check if directories exist before uploading

If the directories to which we upload the maintenance file doesn't
exist, the task fails without any helpful explanation. To get rid of
this bug, test if the directories exist and create them if necessary.