Pogledajte određenu poruku
Staro 12. 03. 2011.   #1
Sasa Kostic
@SasaKostic
Na probnom radu
 
Datum učlanjenja: 15.12.2009
Poruke: 34
Hvala: 17
1 "Hvala" u 1 poruci
Sasa Kostic is on a distinguished road
Post Web app backup na klik

Pravite web app, rad bez backup-a nema mnogo smisla a rucno zipovanje svaki put je dosadno. Ako koristite CI, ovo stavite kao novi kontroler i pozivate ga sa http://localhost/proj/backup npr.
Kôd:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
	<meta http-equiv="Refresh" content="2; URL=http://localhost/proj" />
	<meta name="author" content="" />

	<title>Backup</title>
</head>

<body>

<?php class Backup extends Controller {

    function __construct() {
        parent::Controller();
    }

    function index() {
        
        //DB backup:
        $this->load->dbutil();

        $backup = &$this->dbutil->backup();

        $this->load->helper('file');
        $date = strftime("%d-%b-%y at %Hh%M ");
        $db_backup_file = $date . 'db.gz';

        write_file('d:/htdocs/backup/proj/' . $db_backup_file, $backup);
        //<-DB backup
        
        //proj backup:
        $this->load->lib('zip');
        $path = '../proj/';

        $this->zip->read_dir($path);
        $date = strftime("%d-%b-%y at %Hh%M ");
        $proj_backup_file = $date . 'proj.zip';
        $this->zip->archive('d:/htdocs/backup/proj/' . $proj_backup_file); // Creates a file named myarchive.zip
        $data = 'Done. Redirecting in 2 sec<br> 
        <strong>' . $db_backup_file . '</strong> - '.round((filesize('d:/htdocs/backup/proj/' . $db_backup_file)/1024),1).' KB <br>
        <strong>' . $proj_backup_file . '</strong> - '.round((filesize('d:/htdocs/backup/proj/'.$proj_backup_file)/1024),1).' KB <br>';
        
        $this->out->set_out($data);//display status info
        //<-proj backup
    }

} ?>

</body>
</html>
Sasa Kostic je offline   Odgovorite uz citat