大网数据广告活动
服务器运维问答

Backup to remote server and create tar on the fly

· 52CE 我爱测

I would like to backup a directory from my production server to a backup server using rsync. My current solution: tar directory on production server send to remote server via rsync My Problem with this solution: there is not enou…

问题原文

原帖链接 · T K · CC BY-SA 4.0

I would like to backup a directory from my production server to a backup server using rsync.

My current solution:

  1. tar directory
  2. on production server send to remote server via rsync

My Problem with this solution: there is not enough space to create the tar file + it needs to much resources while the tar is created. It should make as less as possible impact on the production server resources.

I would like to send the files into a tar file on the remote server. I simply could send the files and tar them on the backup server, but in my point of view, this would not be a good solution.

已采纳解答

原帖链接 · Mike Marseglia · CC BY-SA 4.0

You could use a combination of pipes and STDOUT to send the tar file over the network to the remote server.

tar zcvf - /your/directory | ssh -i private.key backup-user@backupserver "cat > /backup/file.tgz"

The "-" character sends the tar to STDOUT which is piped to ssh and the contents written to a regular file using cat.

You'll need to use ssh with a private key file for "passwordless" authentication.

This doesn't use rsync but will get the tarfile to the remote server.

Reference: https://stackoverflow.com/questions/8045479/whats-the-magic-of-a-dash-in-command-line-parameters

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-09-19)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。