Complete implementation: select, archive, copy and extract logs

Pitfalls:

1) in the script written in a here-document and executed with ssh,
some variables must be evaluated from values in the local system,
they are written as $variableName, some must be evaluated from
values in the remote system, they must be escaped as \$variableName
to prevent local evaluation.

2) I used the same variable name remoteArchive for the path of the
archive on remote server, both in local shell and in remote shell.
Since both variables have the same value, this may not be too much
confusing.

3) when the remote script fails, the last line of the standard output
was not the expected file name, but one of the previous outputs
(e.g. welcome log or part of a diagnostic message for an error).
I added an echo of the string "FAILED" in case of failure. As a result,
the local variable remoteArchive contains "FAILED" instead of a path
in case of error, and I added a test for this string to interrupt the
script execution.

4) since sudo with tar to read the contents of the log files,
the archive created is owned by root. As a result, sudo is also
required to delete it at the end of the script.