1

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.

  • 3
    Use an existing backup solution. No need to reinvent the wheel. – Gerald Schneider Sep 19 at 18:04
  • Welcome to Serverfault! It sounds like you have space constraints on your source server, and can't create a tar file. Are you looking for a way to send a tar file to the remote server? Or just send the files over compressed? Perhaps you could re-word this a bit to help us understand your problem a bit better. – Mike Marseglia Sep 19 at 18:06
  • @MikeMarseglia I've edited my question – T K Sep 19 at 18:12
  • 1
    Can you elaborate on why sending the files and tar them on the backup server isn't a good solution from your point of view? It solves the only actual problem you've listed. It's the most straightforward and simple way to achieve what you're trying to do. You can find many tutorials on how to do it doing a google search for remote tar backup. You don't have to send all the files then create a tarball, you can create the tarball on the fly. Also, rsync is the wrong tool for the job if you don't intend to store the files exactly as they are on the source. – yoonix Sep 19 at 18:24
  • 1
    @TK and this is exactly what rsnapshot provides (via a clever use of rsync and hardlinks). I would give it a try. – shodanshok Sep 19 at 20:35
3

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

  • Thank you! This was exactly what I needed. – T K Sep 19 at 18:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.