I am setting up a job to allow me to copy log files as a scheduled batch job on Windows boxes.
The current directory on machine A is:
Logs\ YYYYMMDD\ Logfile1.log
Logfile2.log
Logfile3.log
This machine normally has 3 days worth of logs kept on it at any time.
I have already setup a Robocopy job up as a scheduled task on another server (machine B) to copy the files over to machine B but not to move anything that has already been copied, using this command...
Robocopy "\\machineA\Logs" "\\machineB\LOGSTORAGE\machineA\Logs" /s /zb /r:2 /w:2 /eta /LOG+:\\machineB\LOGSTORAGE\logmove.log /TEE
What I want is to zip the files on machine A and then move them rather than copy them and to ensure I do not then have duplicate zip files created by the job after they have been moved.
I could possibly recreate the folder structure in another location and share this so that machine B has access to the folders as they are but with zip files as the contents, as below:
Logs\ YYYYMMDD\ Logfile1.zip
Logfile2.zip
Logfile3.zip
Ideally, I want the zip to take place using Windows, without the need to install 7Zip or some other compression software. This page mentions PowerShell to do the job but I don't know how I can edit this to my requirements.
As there are likely to be 3 days worth of logs on the machine at any time, is there a way I could ensure that the zip job only compresses files that haven't already been moved over to the final destination?
Can anyone help me with this?