Para recuperar diretórios recursivamente, você precisa usar a diretiva get -r
.
Da manpage do SFTP (1):
get [-Ppr] remote-path [local-path]
Retrieve the remote-path and store it on the local machine. If the local path name is not specified, it is given the same name it has on the remote machine. remote-path may
contain glob(3) characters and may match multiple files. If it does and local-path is specified, then local-path must specify a directory.
If either the -P or -p flag is specified, then full file permissions and access times are copied too.
If the -r flag is specified then directories will be copied recursively. Note that sftp does not follow symbolic links when performing recursive transfers.
Se isso for feito a partir de um trabalho agendado, você precisará adicionar esses comandos a um arquivo de lote e usar a opção -b
.