diff --git a/README.md b/README.md index 844aa89..25980d1 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,8 @@ `dep savefromremote:assets` +`dep savefromremote:logs` + `dep loadtoremote:assets` ## Important diff --git a/ps_silverstripe.php b/ps_silverstripe.php index 9cc734a..5f2bc4e 100644 --- a/ps_silverstripe.php +++ b/ps_silverstripe.php @@ -381,6 +381,31 @@ writeln('=============='); }); +/** + * Save specific logs from server. + * Downloads silverstripe.log, apache2/error.log, and apache2/access.log + */ +task('savefromremote:logs', function () { + writeln('Retrieving specific logs from SiteHost'); + + // Ensure the local directory exists + runLocally('mkdir -p ./from-remote/logs/apache2'); + + // Download silverstripe.log + writeln('Downloading silverstripe.log'); + runLocally('rsync -avzP {{remote_user}}@{{alias}}:/container/logs/silverstripe.log ./from-remote/logs/', ['timeout' => 600]); + + // Download apache2/error.log + writeln('Downloading apache2/error.log'); + runLocally('rsync -avzP {{remote_user}}@{{alias}}:/container/logs/apache2/error.log ./from-remote/logs/apache2/', ['timeout' => 600]); + + // Download apache2/access.log + writeln('Downloading apache2/access.log'); + runLocally('rsync -avzP {{remote_user}}@{{alias}}:/container/logs/apache2/access.log ./from-remote/logs/apache2/', ['timeout' => 600]); + + writeln('Log retrieval completed!'); +}); + /** * Load local assets to server * Makes a temporary copy of current live assets, rolls back to this if there is a transfer issue.