diff --git a/src/Schema.php b/src/Schema.php index 7fdfae4..2f6f459 100644 --- a/src/Schema.php +++ b/src/Schema.php @@ -75,7 +75,7 @@ public function __construct(string $database, string $hostname, string $username ]); } - public function backupTo(string $filename): bool + public function backup(string $filename): bool { $command = "mysqldump -u {$this->username} -p{$this->password} -h {$this->hostname} -P {$this->port} {$this->database} > {$filename}"; @@ -83,6 +83,15 @@ public function backupTo(string $filename): bool return $return_var === 0; } + + public function restore(string $filename): bool + { + $command = "mysql -u {$this->username} -p{$this->password} -h {$this->hostname} -P {$this->port} {$this->database} < {$filename}"; + @exec($command, $output, $return_var); + return $return_var === 0; + } + + static function Create() { //load from .env