For a site that I have, the private files folder is a level above the Drupal root. Whenever a backup is ran (manual or scheduled, it states that it is unable to write to the directory).

Drupal is able to write to the directory because a .htaccess file appeared when the directory was created. I set the private directory permissions to 755 and 775 and neither worked. One of the several error messages that are displayed states

Warning: file_put_contents(main/backup_migrate/manual/.htaccess) [function.file-put-contents]: failed to open stream: No such file or directory in file_create_htaccess() (line 494 of /var/www/bbitmaindrupal/includes/file.inc).

Warning: fopen(main/backup_migrate/manual/test.txt) [function.fopen]: failed to open stream: No such file or directory in backup_migrate_destination_files->check_web_dir() (line 210 of /var/www/bbitmaindrupal/sites/all/modules/backup_migrate/includes/destinations.file.inc).

Another problem that I noticed is that directory mentioned in the error message is not that of the private files directory. The private directory is not named "main", it is named "bbitmaindrupal_main". The path to it is /var/www/bbitmaindrupal_main. I tested by removing the underscore and got the same error, but instead of "main" it said "ain". For some reason, the app is truncating part of the directory path and therefore saying it does not exist.

Comments

wizonesolutions’s picture

Yeah, I'm running into this too. In my case, it is trying to write to, and I quote, private/backup_migrate/manual/test.txt. This is regardless of how I configure the actual destination, too, and whether I use the UI or Drush. This is using 7.x-2.8, and it clearly seems to be either a module problem or a behavior change lacking documentation.

ronan’s picture

Version: 7.x-2.8 » 7.x-2.x-dev
Status: Active » Postponed (maintainer needs more info)

Can you guys try the latest dev (after feb 4). I have a fix for a similar problem in there #2144239: Failed to open stream to read/write b/c filepath gets shortened which makes it invalid. which may sort this out for you. If this I can get more confirmation of this fix I'll roll a release for this and a few other fixes on this branch

thommyboy’s picture

I tried the newest dev november 14 and still the module dos not write outside the site's root.
I try to write to an absolute server path like /var/www/x and for testing the folder is even
set to 777 but still I get "Unable to create or write to the save directory '/var/www/x'.
Please check the file permissions of that directory and try again.

simone960’s picture

Same issue but I'm working on 7.x-2.8. I managed to make a backup outside the root, which is same level with "public_html". However, it only works if the private folder is set to "777" else it fails to write. Now I wonder if this permission is safe if set to 777 ?

couturier’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

The newer versions of the module should have resolved this issue.