TYPO3 Flow Base DistributionPackagesApplications

Feature #49701

Add tasks to deal with mysql dumps

Added by Felix Oertel about 2 years ago. Updated about 2 years ago.

Status:New Start date:2013-07-05
Priority:Should have Due date:
Assigned To:- % Done:

0%

Category:-
Target version:-

Description

Hey,

this allows you to
  • dump database into a file
  • play dumped file into database

Of course working in a two-node-constellation, so you can simply pipe sql from your live-server to your preview-server for example. I will add documentation, as soon as it is given, you want to integrate that feature.

The target of an operation is the node you are currently deploying to (backup would be one exception, as you would backup the current node to a target place.). For now we want to stick to dump database -> write database, so you have to set up a second node, acting as the source. You do this just like a normal node:

$sqlSourceNode = new \TYPO3\Surf\Domain\Model\Node('sqlSource');
$sqlSourceNode->setHostname('www.foertel.com');
$sqlSourceNode->setOption('username', 'foertel');

You can add pathes to the mysqldump or gzip binary, if you have to.

$sqlSourceNode->setOption('mysqldumpBinary', '/usr/bin/mysqldump');
$sqlSourceNode->setOption('gzipBinary', '/bin/gzip');

Next up you have to configure the task itself:

$node->setOption('typo3.surf:mysql:dump', array(
'node' => $sqlSourceNode,
'database' => 'foertelcom',
'username' => 'admin',
'password' => '',
'ignoreTables' => array('tx_extbase_cache_object', 'tx_extbase_cache_object_tags', 'tx_extbase_cache_reflection', 'tx_extbase_cache_reflection_tags'),
'hostname' => 'localhost,
'additionalParameters' => '--single-transaction --quick --lock-tables=false',
));

As you can see, you could just use your node for the 'node'-directive, if that's what you want. ;)

Just add typo3.surf:mysql:dump as a task to your deployment and it will dump your database to a file in /tmp/surf_$releaseIdentifier.sql.gz

Now you could move that file to a backup folder (there is no task for that right now, I have one and will publish it soon, node-based rsync included ;) )

All you can do right now is putting that dump back into a(nother) database. The typo3.surf:mysql:integrate will always use the current node to put the dump in ... makes sense. So just add the task configuration:

$node->setOption('typo3.surf:mysql:integrate', array(
'database' => 'foertelcom',
'username' => 'admin',
'password' => '',
));

and add the task to your deployment.

To clean up the dump after you, just add typo3.surf:mysql:removeTempFile task and you are good to go!

History

#1 Updated by Gerrit Code Review about 2 years ago

Patch set 1 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/21935

Also available in: Atom PDF