Welcome Guest, Not a member yet? Register   Sign In
backup db
#1

[eluser]cinewbie81[/eluser]
Hi all, I'm new here..

I use CI build in library to do my database backup, and the code is as following:

$this->load->dbutil();
$prefs = array(
'ignore' => array('my_ignore_table'),
'format' => 'txt',
'add_drop' => FALSE,
'add_insert' => TRUE,
'newline' => "\n"
);

$backup =& $this->dbutil->backup($prefs);
$this->load->helper('download');
force_download('mybackup.sql', $backup);
The code aboe is working, but it will always backup the file and download it to my Desktop (through force_download function) .. But what i want now is to create a new folder each time i do a backup, and then download the backup file to the new created folder. Is that any way for me to do it ? Hope u guys can help, thanks in advance
#2

[eluser]xwero[/eluser]
I think making folders for each backup is a bit too much, why don't you just use a timestamp in the filename and keep them in one folder?
#3

[eluser]Michael Wales[/eluser]
Yeah, one file per folder... kind of overkill, I personally think.
#4

[eluser]#1313[/eluser]
i am doing backups like this:

Code:
function do_backup() {

        $this->load->dbutil();
        @$backup =& $this->dbutil->backup();
        $this->load->helper('file');
        $filename = date('Ymd',time()).'.mysite.sql.gz';
        $tempdir = './tmp/';
        write_file($tempdir.$filename, $backup);
        $this->load->helper('download');
        force_download($filename, $backup);

}

The only problem is that my backup file is left in the /tmp directory, which is theoretically public, and i am worried by possibility of somebody randomly finding my backup file. I am using this function:

Code:
function clear_tmp() {

        $this->load->helper('file');
        $fnames = get_filenames('./tmp/');
        foreach ($fnames as $filename)
            if ($filename != 'index.html')
                unlink($this->config->item('./tmp/'.$filename);

}

But maybe someone can suggest something more clever? =)
#5

[eluser]sergitin[/eluser]
I think we have to be careful with place where we save backups
I mean about permission (rwx) and owner
and remember that usually user apache makes all the job,
that is in the case that the backup had been saved in the web server

in the other case (the client download the backup)
I think we most not give this
privilege at desktop user




Theme © iAndrew 2016 - Forum software by © MyBB