Tar并将结果直接保存到SSH目录 [英] Tar and save results directly to an SSH directory
问题描述
我有一台服务器,我想为其做tar备份,但是服务器本身没有足够的磁盘空间来与其包含的数据相等.因此,我想直接将其 压缩到ssh目录中,这样它就可以将tar数据转储到ssh目标中,而无需从源服务器获取大量的临时磁盘空间.
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.
服务器应该建立ssh连接,并使用以下形式的目录:
The server is supposed to do an ssh connection and use a directory of the form:
ssh user@server.com:/home/user/backupfolder/
使用简单的Linux终端管道或什至更简单的方法是否有可能?
Is this possible with simple Linux terminal piping or even a simpler way?
推荐答案
是的,这绝对有可能!在要备份的服务器上执行以下操作:
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'
这指示tar
将存档输出到stdout,然后将其通过管道传输并通过ssh
发送以保存到远程文件.
This instructs tar
to output the archive to stdout, which is piped and sent over ssh
to be saved to a remote file.
这篇关于Tar并将结果直接保存到SSH目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!