About

  • Combination of the words "Andri" and "Droid"
  • Sysadmin, developer and a student
  • Born in Reykjavík, Iceland
  • Studying in Aalborg, Denmark
  • Not the Google project

Twitter

  • Nice read. "Programming things I wish I knew" -...
  • wants a compact smartphone that can fit into a man's pocket - why is that so hard?
  • dislike how bloated and annoying phpmyadmin has become? Try SQL Buddy....

Piping remote backups through SSH with tar

While usually operating some sort of backup systems, it may become necessary to perform at remote backup of a machine without initiating locally. There can be a number of reasons to do this, such as:

  • You do not trust the operator of the machine you need to backup from. Various tools may be compromised to grab your passwords.
  • There is no space left on the machine to store the backup file

From the receiving machine (backup to)


# Using bzip2 as compression
ssh user@remote-machine.com "tar cj remote_folder_name1 remote_folder_name2" > backup.tar.bz
# Using gzip as compression
ssh user@remote-machine.com "tar cz remote_folder_name1 remote_folder_name2" > backup.tar.gz

You will be prompted for a password before the command is run. If you need this to be automatic, you can use password-less public key authentication instead (although I will not cover it here). If you risk that your session might die before finishing the copy, try something like 'screen' before running the command.

This shouldn't be much of a revelation to most linux geeks, but useful non the less and written here for documentation purposes.

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.