Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know how to backup a filesystem with tar and restore it later, but i'd like to know how to do that with a remote system. I'm really terrible at all command piping stuff and i can't simply adapt the tutorials to my needs. Any help would be appreciated. What i'd like to do is to login as root@remotemachine and issue a tar command on the entire / directory that would save the resulting archive to my local machine. And then i'd like to do it backwards (restore). I've seen some commands on the net ... something like:

ssh -something root@remotemachine "cd /; tar -cpf - ." | tar -xf -

I don't remember it exactly but i now that this command copied the filesystem over to my computer and i don't know how to change it to create an archive instead.

Thank you

share|improve this question

Use redirection instead of piping in order to create the file on the local system.

ssh ... "... ; tar ..." > foo.tar
share|improve this answer
Thank you, i'll try and report how it went :) And how would i reverse this? Do i have to be connected from the remote machine to the local one to do this, or can i do it from the same local machine? – Marius Oct 14 '10 at 9:00
ssh ... "... ; tar ..x.." < foo.tar – Ignacio Vazquez-Abrams Oct 14 '10 at 9:03
Thanks, i'll try that in a few hours and see how it works. – Marius Oct 14 '10 at 10:01
Probably best to not extract right to the root directory though. – Ignacio Vazquez-Abrams Oct 14 '10 at 10:05

I know it's not what you ask for... but if your goal is to backup, there are much more proven tools to do that over SSH.

You might want to check out Duplicity. It can handle incremental backup, as well as encrypt the backup to name a few features. duplicity /home/me scp://

share|improve this answer
That could be ok, but i'm not sure if it can run on a mac and i'm not sure if it would work for the iphone (that's what i'm trying to backup) – Marius Oct 14 '10 at 8:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .