I have an lftp script file that I use for mirroring some directories over sftp, so I run the command using something like lftp -f mirror_dirs.lftp
. I would now like to log the transfers to a specific log file so that later, perhaps in a forensic context, I can determine what files were transferred and when. I don't want to put options in a file like ~/.lftp/rc
since I don't want to pollute my log file with information from other, ad-hoc, lftp commands I might issue. I have read the lftp manual and remain quite confused.
It seems like what I want to do is log transfers. The manual mentions the following:
log:enabled (boolean) when true, the log messages are output. The closure for this and other 'log:' variables is either `debug' for debug messages or 'xfer' for transfer logging. log:file (string) the target output file for logging. When empty, stderr is used.
This "closure" business is particularly confusing to me, as is its syntax. As far as I can tell the "closure" is a way to provide a more specific context for a command. Here was my initial attempt:
set log/xfer:enabled true
set log/xfer:file "/Logs/lftp_transfer.log"
set log/xfer:show-time true
set mirror:parallel-directories true
open "sftp://user99:[email protected]"
mirror --verbose -c / tests/
which resulted in the error message /Logs/lftp_transfer.log: invalid boolean value
, so obviously I have not understood the syntax.
How can I correctly specify transfer logging in an lftp script file.
set xfer:log 1 set xfer:log-file "/Logs/lftp_transfer.log"