Tar and save results directly to an SSH directory

那年仲夏 提交于 2019-12-12 06:15:40

问题


I have a server that I would like to make a tar backup of, but the server itself doesn't have enough disk space that is equal to the data it contains. Therefore, I would like to tar it directly to an ssh directory, such that it would dump the tar data into the ssh target without taking huge temporary disk space from the source server.

The server is supposed to do an ssh connection and use a directory of the form:

ssh user@server.com:/home/user/backupfolder/

Is this possible with simple Linux terminal piping or even a simpler way?


回答1:


Yes, this is absolutely possible! Do the following from the server you're backing up:

tar czv <stuff to backup> | ssh user@server.com 'cat > /home/user/backupfolder/backup.tar.gz'

This instructs tar to output the archive to stdout, which is piped and sent over ssh to be saved to a remote file.



来源:https://stackoverflow.com/questions/30058584/tar-and-save-results-directly-to-an-ssh-directory

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!