拉入UNIX时拉动文件和zip

时间:2021-06-19 09:46:43

I am generating files from netezza server using nzsql. Now the next part of the requirement is to zip and move the file into a different box (a second unix box). I can achieve this sitting in the 1st box (sitting in the first box I am first doing gzip and then moving the file using scp). But my question is, can this be done directly from the 2nd box. Means in the 1st box there will be the files which will be generated nzsql and in the 2nd box that file will be pulled and while pulling it will be zipped (using mkfifo or by any other means). In the 1st box I don't want the zip file to be created or resides. Please let me know how this can be achieved.

我使用nzsql从netezza服务器生成文件。现在,要求的下一部分是压缩并将文件移动到另一个框(第二个unix框)。我可以在第一个框中实现这一点(坐在第一个框中我首先使用gzip,然后使用scp移动文件)。但我的问题是,这可以直接从第二个方框完成。在第一个方框中的意思是将生成nzsql的文件,在第二个方框中该文件将被拉动,同时拉动它将被压缩(使用mkfifo或通过任何其他方式)。在第一个框中,我不希望创建或驻留zip文件。请告诉我这是如何实现的。

1 个解决方案

#1


you can in your box 2, have this running periodically:

你可以在你的盒子里2,定期运行:

rsync -azP user@box1:/path/to/your/sync/folder /dst/folder

the parameter explanation are directly copied from man page:

参数说明直接从手册页复制:

-a, --archive archive mode; equals -rlptgoD (no -H,-A,-X)

-a, - archive archive mode;等于-rlptgoD(无-H,-A,-X)

-r, --recursive recurse into directories

-r, - 递归递归到目录中

-l, --links copy symlinks as symlinks

-l, - 将符号链接复制为符号链接

-p, --perms preserve permissions

-p, - perms保留权限

-D same as --devices --specials

-D与--devices --specials相同

--devices preserve device files (super-user only)

--devices保存设备文件(仅限超级用户)

--specials preserve special files

--specials保留特殊文件

-t, --times preserve modification times

-t, - 保存修改时间

-o, --owner preserve owner (super-user only)

-o, - 所有者保留所有者(仅限超级用户)

-g, --group preserve group

-g, - group保留组

-z, --compress compress file data during the transfer

-z, - 在传输过程中压缩压缩文件数据

-P same as --partial --progress

-P与--partial --progress相同

--partial keep partially transferred files

--partial保留部分传输的文件

but i doubt whether it's proper or not. you should push it from box1 to minimize the bandwidth usage. pulling is almost the same as polling.

但我怀疑它是否合适。你应该从box1推送它以最小化带宽使用。拉动几乎与民意调查相同。

reference here is a very complete tutorial: https://www.digitalocean.com/community/tutorials/how-to-use-rsync-to-sync-local-and-remote-directories-on-a-vps

这里引用的是一个非常完整的教程:https://www.digitalocean.com/community/tutorials/how-to-use-rsync-to-sync-local-and-remote-directories-on-a-vps

#1


you can in your box 2, have this running periodically:

你可以在你的盒子里2,定期运行:

rsync -azP user@box1:/path/to/your/sync/folder /dst/folder

the parameter explanation are directly copied from man page:

参数说明直接从手册页复制:

-a, --archive archive mode; equals -rlptgoD (no -H,-A,-X)

-a, - archive archive mode;等于-rlptgoD(无-H,-A,-X)

-r, --recursive recurse into directories

-r, - 递归递归到目录中

-l, --links copy symlinks as symlinks

-l, - 将符号链接复制为符号链接

-p, --perms preserve permissions

-p, - perms保留权限

-D same as --devices --specials

-D与--devices --specials相同

--devices preserve device files (super-user only)

--devices保存设备文件(仅限超级用户)

--specials preserve special files

--specials保留特殊文件

-t, --times preserve modification times

-t, - 保存修改时间

-o, --owner preserve owner (super-user only)

-o, - 所有者保留所有者(仅限超级用户)

-g, --group preserve group

-g, - group保留组

-z, --compress compress file data during the transfer

-z, - 在传输过程中压缩压缩文件数据

-P same as --partial --progress

-P与--partial --progress相同

--partial keep partially transferred files

--partial保留部分传输的文件

but i doubt whether it's proper or not. you should push it from box1 to minimize the bandwidth usage. pulling is almost the same as polling.

但我怀疑它是否合适。你应该从box1推送它以最小化带宽使用。拉动几乎与民意调查相同。

reference here is a very complete tutorial: https://www.digitalocean.com/community/tutorials/how-to-use-rsync-to-sync-local-and-remote-directories-on-a-vps

这里引用的是一个非常完整的教程:https://www.digitalocean.com/community/tutorials/how-to-use-rsync-to-sync-local-and-remote-directories-on-a-vps