Recover remote tar backup with ssh

ssh user@host "cat /path/to/backup/backupfile.tar.bz2" |tar jpxf -
Here how to recover the remote backup over ssh
Sample Output
[nothing]

8
By: mack
2010-03-24 01:35:28

These Might Interest You

  • Execute it from the source host, where the source files you wish backup resides. With the minus '-' the tar command deliver the compressed output to the standar output and, trough over the ssh session to the remote host. On the other hand the backup host will be receive the stream and read it from the standar input sending it to the /path/to/backup/backupfile.tar.bz2 Show Sample Output


    13
    tar jcpf - [sourceDirs] |ssh user@host "cat > /path/to/backup/backupfile.tar.bz2"
    mack · 2010-03-24 01:29:25 0
  • This command will nicely dump a filesystem to STDOUT, compress it, encrypt it with the gpg key of your choice, throttle the the data stream to 60kb/s and finally use ssh to copy the contents to an image on a remote machine. Show Sample Output


    2
    nice -n19 dump -0af - /<filesystem> -z9|gpg -e -r <gpg key id>|cstream -v 1 -t 60k|ssh <user@host> "cat > backup.img"
    din7 · 2009-10-29 18:27:25 0
  • With this cron, rsync begins to sinchronize the contents of the local directory on /[VIPdirectory] with the directory /backup/[VIPdirectory] on the remote server X.X.X.X. Previously we need working on public/private-keys ssh to guarantee the acces to the remote server on X.X.X.X Show Sample Output


    5
    0 10 * * * rsync -rau /[VIPdirectory] X.X.X.X:/backup/[VIPdirectory]
    mack · 2010-03-02 17:48:54 0
  • backup big mysql db to remote machine over ssh. "--skip-opt" option is needed when you can?t allocate full database in ram.


    9
    mysqldump -q --skip-opt --force --log-error=dbname_error.log -uroot -pmysqlpassword dbname | ssh -C user@sshserver 'cd /path/to/backup/dir; cat > dbname.sql'
    esplinter · 2010-05-29 23:06:04 0

What Others Think

I've seen it before, where you remotely cat a file via ssh to grab its contents. Why do that versus just scp it?
vgm64 · 430 weeks and 2 days ago
Because with this cat you don't need the whole file on the target host. With scp you need the additional storage to copy the compressed file to the target host before extract it. If you have a very huge file (hundreds of GB or TB); then, this way is the best choice.
mack · 373 weeks and 4 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: