简体   繁体   English

通过 rsync 将过滤后的文件内容复制到远程服务器

[英]copy filtered content of file to remote server via rsync

I know how to copy files between servers using rsync.我知道如何使用 rsync 在服务器之间复制文件。 But I was looking for an option where I donot want to copy entire content file on another server.但我正在寻找一个选项,我不想将整个内容文件复制到另一台服务器上。 Example:- I want to copy /var/log/messages filtered by todays date on remote server in todays date folder and tomorrows content in tomorrows date folder and so on.示例:- 我想复制今天日期文件夹中远程服务器上的今天日期过滤的/var/log/messages和明天日期文件夹中的明天内容等等。 Though I can achieve the same by creating temporary files in local node before transferring, but I am looking for a solution where filtered data can be transferred to remote server without creating any local temporary file虽然我可以通过在传输之前在本地节点中创建临时文件来实现相同的目的,但我正在寻找一种解决方案,可以将过滤后的数据传输到远程服务器而无需创建任何本地临时文件

where filtered data can be transferred to remote server without creating any local temporary file过滤后的数据可以在不创建任何本地临时文件的情况下传输到远程服务器

Just the same way you do locally, just cat the output to the remote.与您在本地执行的操作相同,只需将 output 连接到远程即可。 Along:沿着:

cat /var/log/messages | awk 'some filtering here' | ssh server 'cat > /the/destination'

Repeat the process for each file.对每个文件重复该过程。

The simpler is just the same as creating temporary files you want to transfer - just create them at the destination!更简单的方法与创建要传输的临时文件相同 - 只需在目的地创建它们! Mount sshfs the remote and create them inside the mountpoint.挂载sshfs远程并在挂载点内创建它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM