Doesn't seem to work with drupal in subdir
ariflukito - December 12, 2008 - 04:42
| Project: | Backup Files |
| Version: | 6.x-1.1 |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
Description
I have drupal installed in a subdir (/drupal) and backup files unable to locate the directories specified for backup. I managed to get it to work by changing line 157 from $rp = realpath('.'. $bp. trim($dir)); to $rp = realpath(trim($dir));

#1
I have Drupal 6.9 installed in a sub-directory and I tried the code fix above and got the same error message as before, "Does not exist: /sites/all/themes/" until I added a period in front of the backup directory path.
"Test Settings" didn't work: /sites/all/modules
"Test Settings" worked: ./sites/all/modules
Unfortunately, when I tried to do an actual backup, the file that got downloaded was empty.
Error message:
warning: filesize() [function.filesize]: stat failed for /backup.tgz in /[my-path]/sites/all/modules/backup_files/backup_files.module on line 216.
warning: fopen(/backup.tgz) [function.fopen]: failed to open stream: No such file or directory in /[my-path]//sites/all/modules/backup_files/backup_files.module on line 220.
#2
#3
#4
With minor changings and a existing and writable tmp-dir it's working for me in a subdir.
Thx.
#5
Just a note that this patch doesn't work for me, although I have the same issue. The module is not finding the files, or looking in the correct location. I'm on a LAMP server with Drupal installed (for the moment) in a subdirectory.
#6
So I'm marking this as "needs work", because this patch evidently doesn't solve the problem generally enough.
#7
The problem is that base_path() (which is used in this function) returns the base *url*, not the base file path. You can't really make assumptions about how to derive a path from this -- it is very dependent on the web server, Drupal installation, etc.
You need to instead do something like what conf_path() does, or better yet just use conf_path(). If the module is meant to only backup files within the sites/whatever/files directory, then file_directory_path() will give you a path to that directory.
#8
For me this patch works :
On backup_files.module, replace in line 155 :
<?php$rp = realpath('.'. $bp. trim($dir));
?>
by :
<?php$rp = realpath('./' . trim($dir));
?>
And replace in line 172 :
<?php$bfn = realpath('.'. $bp. $temp). '/backup.tgz';
?>
by :
<?php$bfn = realpath('./' . $temp). '/backup.tgz';
?>
And you can remove line 131 too.
It works with drupal installed in sub directory and in root directory