问题
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