Take the 2-minute tour ×

Im using

tar zcf - stuff | ssh user@server 'cat > data.tar.gz'

Is there a way to split the file on transfer?

Something like this:

tar zcf - stuff | split -b 5G | ssh user@server 'cat > data-${part}.tar.gz'

Thanks in advance!

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Yes, the command is called split.

tar czf - stuff | split -b 5G -d -f 'ssh server "cat >$FILE"'

This option is new in Ubuntu 12.04. With previous versions, split can only split to files, not to commands. The files can be named pipes, but organizing the commands to read from the pipes is cumbersome.

Without split -f, an easier approach is to forget about using a command. Mount the remote filesystem with sshfs instead, so that you can write to it as if it was a local file.

mkdir ~/net/server
sshfs user@server ~/net/server
tar czf - stuff | (cd ~/net/server && split -b 5G -d)
fusermount -u ~/net/server

You might be interested in a proper backup software such as duplicity instead.

share|improve this answer
Thanks! This seems to work. And: sshfs is not installed on the server and I'm not the administrator... –  Andreas Oct 29 '12 at 17:54
@Andreas If FUSE is available (specifically, the fuse package, which contains privileged components), you can install SSHFS manually. It's a lot more hassle than a simple package installation, of course, so if you aren't the admin it's only worth doing it if you do nontrivial manipulations of remote files often. –  Gilles Oct 29 '12 at 18:10

Your Answer


