Skip to content

Commit

Permalink
IMplement log download (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
brad-ps authored Aug 1, 2024
1 parent 7f41898 commit 0716839
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

`dep savefromremote:assets`

`dep savefromremote:logs`

`dep loadtoremote:assets`

## Important
Expand Down
25 changes: 25 additions & 0 deletions ps_silverstripe.php
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,31 @@
writeln('<info>==============</info>');
});

/**
* Save specific logs from server.
* Downloads silverstripe.log, apache2/error.log, and apache2/access.log
*/
task('savefromremote:logs', function () {
writeln('<info>Retrieving specific logs from SiteHost</info>');

// Ensure the local directory exists
runLocally('mkdir -p ./from-remote/logs/apache2');

// Download silverstripe.log
writeln('<comment>Downloading silverstripe.log</comment>');
runLocally('rsync -avzP {{remote_user}}@{{alias}}:/container/logs/silverstripe.log ./from-remote/logs/', ['timeout' => 600]);

// Download apache2/error.log
writeln('<comment>Downloading apache2/error.log</comment>');
runLocally('rsync -avzP {{remote_user}}@{{alias}}:/container/logs/apache2/error.log ./from-remote/logs/apache2/', ['timeout' => 600]);

// Download apache2/access.log
writeln('<comment>Downloading apache2/access.log</comment>');
runLocally('rsync -avzP {{remote_user}}@{{alias}}:/container/logs/apache2/access.log ./from-remote/logs/apache2/', ['timeout' => 600]);

writeln('<info>Log retrieval completed!</info>');
});

/**
* Load local assets to server
* Makes a temporary copy of current live assets, rolls back to this if there is a transfer issue.
Expand Down

0 comments on commit 0716839

Please sign in to comment.