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

RickA99 - February 17, 2009 - 15:14

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.

function backup_files_download($filename, $filetype, $file_path) {
header('Content-Type: '. $filetype);
header('Expires: '. gmdate('D, d M Y H:i:s') .' GMT');
header('Content-Length: '. filesize($file_path)); <--------------line 216
header('Content-Disposition: attachment; filename="'. $filename .'"');

// Transfer file in 1024 byte chunks to save memory usage.
if ($fd = fopen($file_path, 'rb')) { <--------------line 220
while (!feof($fd)) {
print fread($fd, 1024);
}
fclose($fd);
}

module_invoke_all('exit');
exit();
}

#2

mikeytown2 - February 24, 2009 - 23:41
AttachmentSize
backup_files.patch 777 bytes

#3

mikeytown2 - February 25, 2009 - 01:17
Status:active» needs review

#4

davidjany - May 8, 2009 - 15:22

With minor changings and a existing and writable tmp-dir it's working for me in a subdir.

Thx.

AttachmentSize
backup_files.patch 1.33 KB

#5

jhodgdon - July 31, 2009 - 23:41

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

jhodgdon - July 31, 2009 - 23:42
Status:needs review» needs work

So I'm marking this as "needs work", because this patch evidently doesn't solve the problem generally enough.

#7

jhodgdon - July 31, 2009 - 23:54

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

sinasquax - August 3, 2009 - 11:41

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

 
 

Drupal is a registered trademark of Dries Buytaert.