Skip to content

Instantly share code, notes, and snippets.

@khairulhasanmd
Last active July 23, 2019 14:54
Show Gist options
  • Save khairulhasanmd/8130413c6d15bba5c7bb to your computer and use it in GitHub Desktop.
Save khairulhasanmd/8130413c6d15bba5c7bb to your computer and use it in GitHub Desktop.
codeigniter-db-backup
<?php
//http://codepen.io/noeldelgado/pen/NPGmRO
//http://codepen.io/mr_alien/pen/FDLjg
//http://codepen.io/simeydotme/pen/jgcvi
//http://codepen.io/notduncansmith/pen/ogbwEv
//http://codepen.io/kowlor/pen/ZYYQoy
//http://codepen.io/aurer/pen/jEGbA
//http://codepen.io/lukerichardville/pen/NGPMMJ
//http://codepen.io/isuttell/pen/OPVELL
//http://codepen.io/digiti/pen/OPpLBj
//http://codepen.io/satcy/pen/ltxLC
//http://codepen.io/yashbhardwaj/pen/hHgtE
//http://codepen.io/djfreak/pen/JbnAx
//http://codepen.io/pixelass/pen/PPPmaL
//http://codepen.io/JonasB/pen/PwWXqg
//address http://codepen.io/marlenesco/pen/NqOozj
//http://codepen.io/SaschaSigl/pen/gpVKOa
$this->load->dbutil();
$prefs = array(
'format' => 'zip',
'filename' => 'my_db_backup.sql'
);
$backup =& $this->dbutil->backup($prefs);
$db_name = 'backup-on-'. date("Y-m-d-H-i-s") .'.zip';
$save = '/upload/_tmp/'.$db_name;
$this->load->helper('file');
write_file($save, $backup);
$this->load->helper('download');
force_download($db_name, $backup);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment