Skip to content

Instantly share code, notes, and snippets.

@ADoebeling
Last active March 16, 2016 11:46
Show Gist options
  • Save ADoebeling/e78e9bafda5e1e1ff9e9 to your computer and use it in GitHub Desktop.
Save ADoebeling/e78e9bafda5e1e1ff9e9 to your computer and use it in GitHub Desktop.
Stored in the dir about /htdocs/ it will dump the mysql-db that's configured in the contao localconfig.php

1601.com contaoMysqlDump

Setup-instruction

  • Switch into www-dir (above htdocs) of your project

  • Download this script:
    git clone git@gist.github.com:e78e9bafda5e1e1ff9e9.git

  • Rename folder:
    mv e78e9bafda5e1e1ff9e9 contaoMysqlDump

Backup-instruction

  • Perform a backup:
    php56 contaoMysqlDump/contaoMysqlDump.php

  • Check created backups:
    l -h contaoMysqlDump/
    (If files > 10 MB stop here and ask your admin how to continue)

  • Git-Checkin:
    git add contaoMysqlDump && git commit -m "Adding new MySQL-Backup using contaoMysqlDump" --author=$XXX

  • You're done!

Support?

<?php
/**
* Contao mysqlDump
* *
* @author Andreas Doebeling <ad@1601.com>
* @copyright 1601.production siegler&thuemmler ohg
* @link http://www.1601.com
* @link http://xing.doebeling.de
* @link https://gist.github.com/ADoebeling/e78e9bafda5e1e1ff9e9
*/
require_once '../htdocs/system/config/localconfig.php';
$cmd = "mysqldump -h {$GLOBALS['TL_CONFIG']['dbHost']} -u {$GLOBALS['TL_CONFIG']['dbUser']} -p{$GLOBALS['TL_CONFIG']['dbPass']} {$GLOBALS['TL_CONFIG']['dbDatabase']} --default-character-set=utf8 --routines -d > {$GLOBALS['TL_CONFIG']['dbDatabase']}_structure_1srv.sql";
passthru($cmd);
$cmd = "mysqldump -h {$GLOBALS['TL_CONFIG']['dbHost']} -u {$GLOBALS['TL_CONFIG']['dbUser']} -p{$GLOBALS['TL_CONFIG']['dbPass']} {$GLOBALS['TL_CONFIG']['dbDatabase']} --default-character-set=utf8 --no-create-info | gzip -c > {$GLOBALS['TL_CONFIG']['dbDatabase']}_data_1srv.sql.gz";
passthru($cmd);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment