I'm wanting to copy a file and gzip it in a single command/step
But I want to do numbered backup if the file already exists i.e. "cp --backup=numbered" or similar.
The reason for the single step is that I'm copying a log file (which can be large) to a network filesystem. The filesystem is not nfs and I cannot use scp. I must use regular unix commands. Actually the filesystem is cephfs.
I thought perhaps a zcat logfile > /dest/logfile but what about numbered backup?
This whole problem arose because logrotate only starts gzipping on the 2nd rotate operation not the first. i.e. live (today), yesterday (.1 - not gzipped), day before yesterday (.2 - gzipped). Kindof annoying.
If I gzip before copy I think that might mess with logrotate.