Skip to content

Commit

Permalink
backup and restore
Browse files Browse the repository at this point in the history
  • Loading branch information
mathsgod committed Jan 19, 2023
1 parent c6fd833 commit 0cf8cba
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,23 @@ 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}";
@exec($command, $output, $return_var);
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
Expand Down

0 comments on commit 0cf8cba

Please sign in to comment.