将 90 天前的文件通过 scp 或 rsync 同步到远程服务器 (EC2)

Scp or rsync 90 days older files to remote server (EC2)

我正在尝试获取早于 90 天的日志文件,并尝试将它们发送到作为 ec2 实例的远程服务器。我正在尝试这个命令,但它不起作用。

find /var/log/* -mtime +90 -print0 | rsync --remove-source-files -av -e ssh -i keypair.pem ubuntu@ip:/

它给出了这个错误:

ubuntu@ip: Permission denied (publickey).
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(235) [sender=3.1.3]

-i 是 ssh 的选项,不是 rsync。您正在使用 -e。很好,但是您必须将引号中的所有 ssh 参数传递给它。 第二件事你必须告诉 rsync 你正在通过 stdin

管道传输一些东西

find /var/log/* -mtime +90 -print0 | rsync --remove-source-files -av -e 'ssh -i keypair.pem' --files-from=- --from0 /var/log/ ubuntu@ip:/

https://unix.stackexchange.com/questions/87018/find-and-rsync