使用Bash脚本来scp远程服务器上目录中的最新文件

bea*_*ker 9 bash backup cron scp database-backups

好的,所以我知道如何使用find then cp命令在本地执行此操作,但不知道如何使用scp远程执行相同操作.

所以知道这个:

scp -vp me@server:/target/location/ /destination/dir/.
Run Code Online (Sandbox Code Playgroud)

该目标目录将充满数据库备份,如何告诉它查找最新备份,以及本地scp?

Dig*_*oss 11

remote_dir=/what/ever
dst=remote-system.host.name.com
scp $dst:`ssh $dst ls -1td $remote_dir/\* | head -1` /tmp/lastmod
Run Code Online (Sandbox Code Playgroud)