Skip to content

Commit

Permalink
add option to specify timeout of mysqldump
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze committed Jun 4, 2015
1 parent 83dc7da commit 8b5e26a
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

All Notable changes to `laravel-backup` will be documented in this file

###2.5.0
- Added option to specify the timeout of the mysqldump command

###2.4.2
- Fixed an issue where the incorrect backup filename would be displayed

Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ return [
* See: https://dev.mysql.com/doc/refman/5.1/en/mysqldump.html#option_mysqldump_extended-insert
*/
'useExtendedInsert' => false,

/*
* If the dump of the db takes more seconds that the specified value,
* it will abort the backup.
*/
'timeoutInSeconds' => 60,
],
];
```
Expand Down
5 changes: 4 additions & 1 deletion src/BackupHandlers/Database/Databases/MySQLDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class MySQLDatabase implements DatabaseInterface
* @param $password
* @param $host
* @param $port
* @param $socket
*/
public function __construct(Console $console, $database, $user, $password, $host, $port, $socket)
{
Expand Down Expand Up @@ -62,7 +63,9 @@ public function dump($destinationFile)
escapeshellcmd($this->getSocketArgument())
);

return $this->console->run($command);


return $this->console->run($command, config('laravel-backup.mysql.timeoutInSeconds'));
}

/**
Expand Down
11 changes: 9 additions & 2 deletions src/Console.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,18 @@

class Console
{
public function run($command)
/**
* Run a command in the shell.
*
* @param $command
* @param $timeoutInSeconds
* @return bool|string
*/
public function run($command, $timeoutInSeconds = 60)
{
$process = new Process($command);

$process->setTimeout(60 * 1);
$process->setTimeout($timeoutInSeconds);

$process->run();

Expand Down
6 changes: 6 additions & 0 deletions src/config/laravel-backup.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,11 @@
* See: https://dev.mysql.com/doc/refman/5.1/en/mysqldump.html#option_mysqldump_extended-insert
*/
'useExtendedInsert' => false,

/*
* If the dump of the db takes more seconds that the specified value,
* it will abort the backup.
*/
'timeoutInSeconds' => 60,
],
];

0 comments on commit 8b5e26a

Please sign in to comment.