Last active
June 8, 2017 08:32
-
-
Save hslatman/ea433437307a7bb9473d to your computer and use it in GitHub Desktop.
Create a Magento database backup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/****************************************************************************************************************** | |
* Source: http://www.emvee-solutions.com/blog/magento-create-database-backup-php-code/ | |
* | |
* Creating a Magento database backup in var/backups | |
******************************************************************************************************************/ | |
//increase execution time | |
ini_set('max_execution_time', 900); //900 seconds = 15 minutes | |
//require Magento | |
require_once 'app/Mage.php'; | |
$app = Mage::app('admin'); | |
umask(0); | |
//set error reporting | |
error_reporting(E_ALL & ~E_NOTICE); | |
Mage::setIsDeveloperMode(true); | |
//do backup | |
try { | |
$backupDbHelper = Mage::getModel('backup/db'); | |
//create backup instance, set certain options | |
$backup = Mage::getModel('backup/backup') | |
->setTime(time()) | |
->setType('db') | |
->setPath(Mage::getBaseDir("var") . DS . "backups"); | |
//do actual backup | |
$backupDbHelper->createBackup($backup); | |
//return success | |
print 'Backup successfully created'; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment