Welcome Guest, Not a member yet? Register   Sign In
backup to variable don't work
#1

[eluser]Chalda Pnuzig[/eluser]
Hi all,
I have this code:
Code:
function backup(){
    $this->CI =& get_instance();
    $this->CI->load->dbutil();
    $this->CI->load->helper('file');
    $backup = & $this->CI->dbutil->backup();
    $filename='backup/db.'.date("YmdHi").'.sql.gz';
    write_file($filename, $backup);
}

The problem is the function don't create the file, but do a "force download" to a empty file called like the url...
Why?

This is the log:
Code:
DEBUG - 2008-05-26 01:57:32 --> Database Forge Class Initialized
DEBUG - 2008-05-26 01:57:32 --> Database Utility Class Initialized
DEBUG - 2008-05-26 01:57:32 --> Database Forge Class Initialized
DEBUG - 2008-05-26 01:57:32 --> Database Utility Class Initialized
DEBUG - 2008-05-26 01:57:32 --> Helpers loaded: file
#2

[eluser]gtech[/eluser]
nevermind next post makes more sense.
#3

[eluser]gtech[/eluser]
reading the code a bit more if the format is txt, all that dbutil->backup($prefs); returns is a string.. you could echo that string to see if you are getting anything back

Code:
$prefs = array(
                'format'      => 'txt',             // gzip, zip, txt
              );
  echo $this-CI->dbutil->backup($prefs);

if you are then the problem is with the write_file, you could do a check to see if you have write permissions to the folder..

The problem is the backup code does not appear to log anything so you will not see any error message, so its worth doing the check.


you could also check write_file as follows
Code:
...
    $this->CI->load->helper('file');
    $data = 'Some file data';
    $filename='backup/db.'.date("YmdHi").'.txt';

    if ( ! write_file($filename, $data))
    {
       echo 'Unable to write the file';
    }
    else
    {
       echo 'File written!';
    }
#4

[eluser]Chalda Pnuzig[/eluser]
Uh...
I try it after lunch and it's working... :bug:
Mmm... Bizarre :exclaim:
#5

[eluser]gtech[/eluser]
cool a self code fixing computer, I want one, where did you get it from?
#6

[eluser]Chalda Pnuzig[/eluser]
Top secret Big Grin
Thanks anyway!
#7

[eluser]Chalda Pnuzig[/eluser]
I found the problem: Too low memory! :roll:

I put this in the function and all works great
Code:
ini_set('memory_limit', '64M');




Theme © iAndrew 2016 - Forum software by © MyBB