Skip to content

Commit

Permalink
Adding some additional logging (#2)
Browse files Browse the repository at this point in the history
* Adding some additional logging information

* updating the readme file

* Update README.md

* Update README.md

---------

Co-authored-by: Terry Karavoulias <[email protected]>
  • Loading branch information
tekavou and Terry Karavoulias authored May 5, 2023
1 parent 7e574d4 commit 8cb91a8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,12 @@ With Plan:

```bash
artisan mysql-snapshot:load daily
```
```

**Additional options**

`--cached` Keeps a copy of the snapshot so that you don't need to redownload it on the next run

`--recached` Downloads a fresh sql file, even if one exists locally, and then keeps it cached

`--no-drop` Do not drop all tables in the database before loading the snapshot
10 changes: 9 additions & 1 deletion src/Snapshot.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,19 @@ public function removeLocalCopy(): void
public function download($useLocalCopy = false): bool
{
if ($useLocalCopy && $this->existsLocally()) {
$this->info('Using local snapshot');

return false;
}

$archiveFile = "{$this->snapshotPlan->archivePath}/{$this->fileName}";

$fileSize = round($this->snapshotPlan->archiveDisk->getSize($archiveFile) / 1024 / 1024) . 'MB';

$this->info("Downloading remote snapshot ($fileSize)..");
$this->snapshotPlan->localDisk->put(
"{$this->snapshotPlan->localPath}/{$this->fileName}",
$this->snapshotPlan->archiveDisk->get("{$this->snapshotPlan->archivePath}/{$this->fileName}")
$this->snapshotPlan->archiveDisk->get($archiveFile)
);

return true;
Expand All @@ -51,6 +58,7 @@ public function load($useLocalCopy = false, $keepLocalCopy = false): void
$zcatUtil = config('mysql-snapshots.utilities.zcat');
$mysqlUtil = config('mysql-snapshots.utilities.mysql');

$this->info('Running SQL commands');
$this->snapshotPlan->runCommandWithMysqlCredentials(
"$zcatUtil $mysqlDumpFile | $mysqlUtil --defaults-extra-file={credentials_file} {database}"
);
Expand Down

0 comments on commit 8cb91a8

Please sign in to comment.