Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update PowerShell script to match archive.sh #2848

Closed
anonymous-matomo-user opened this issue Jan 4, 2012 · 6 comments
Closed

Update PowerShell script to match archive.sh #2848

anonymous-matomo-user opened this issue Jan 4, 2012 · 6 comments
Labels
Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. wontfix If you can reproduce this issue, please reopen the issue or create a new one describing it.
Milestone

Comments

@anonymous-matomo-user
Copy link

I saw in the comments of 1411 that the PowerShell script for archiving needed to be updated to match the latest archive.sh

The attached file does that as well as a few other improvements. Here is the summary of changes:

  • Added test for the existence of the INI file so that script will fail if the INI file location is bad (which typically happens after upgrade if your INI is in a different location than the default used in the script)
  • Added function that is used to call to PHP.exe so that exit codes from the exe are trapped and the script is halted with an error if PHP returns a non-zero error code.
    This was added because I have been experiencing issues where PHP.exe CLI will crash when running archive but it does so silently when the archive is in a scheduled task. This should now cause the scheduled task to fail if the PHP.exe fails. This does not cover errors that are returned from the Piwik API
  • Made the token a replacement tag in the command arguments so that the error text for failure does not contain the actual token value.
  • Changed Write-Host to Write-Output which is better form since output can be redirected but Write-Host cannot.
  • Changed errors to use Write-Error which is better PowerShell convention.
  • Added Write-Verbose statement for PHP command arguments so that full arguments beign sent to the command can be inspected for debugging.
  • Added segments archiving to match the archive.sh file
  • Added ability to turn on logging of the PowerShell script to a log file. Log files rotate and the number of rotating logs is based on the $NUM_LOGS_TO_KEEP varaible at the top of the script. To turn on transcript logging, set $LOGGING_ENABLED to $true. The one drawback to this right now is that it doesn't capture the output of the PHP.exe so you don't get to see if there were errors returned from Piwik API.

If someone could get this into the codebase so that it becomes part of the next release, it would be much appreciated.
Keywords: powershell, archive

@anonymous-matomo-user
Copy link
Author

Attachment: Upgraded archive.windows.ps1 file.
archive.windows.upgraded.ps1

@anonymous-matomo-user
Copy link
Author

Sorry that I didn't format that list very well; I wasn't thinking about it being wiki syntax.

@anonymous-matomo-user
Copy link
Author

And one more comment. The command line parameters for powershell when calling it from a scheduled task should be: Noninteractive Noprofile File "C:\inetpub\wwwroot\piwik\misc\cron\archive.windows.ps1"

Remove the curly braces and the ampersand and use the -File parameter rather than the -Command parameter. It's simpler and it's easier to read / understand.

Please update the documentation to reflect this.

@mattab
Copy link
Member

mattab commented Jan 8, 2012

Thank you for your contribution!

Feedback

@mattab
Copy link
Member

mattab commented Feb 8, 2012

Volox did you see my last comment? your answer would be very appreciated (otherwise will mark as wont fix since we will now have #2327 )

@mattab
Copy link
Member

mattab commented Jan 31, 2014

In 916d8d6: Starting January 2014, this script is now deprecated. Please only use the standard archive.php script in your scheduled task setup. See documentation at: http://piwik.org/docs/setup-auto-archiving/ Refs #1959 #1411 #2848

@anonymous-matomo-user anonymous-matomo-user added this to the 1.7.x - Piwik 1.7.1 milestone Jul 8, 2014
sabl0r pushed a commit to sabl0r/piwik that referenced this issue Sep 23, 2014
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. wontfix If you can reproduce this issue, please reopen the issue or create a new one describing it.
Projects
None yet
Development

No branches or pull requests

2 participants