Create TAR over SSH

Step-by-Step descriptions of how to do things.
Post Reply
User avatar
peter_b
Chatterbox
Posts: 378
Joined: Tue Nov 12, 2013 2:05 am

Create TAR over SSH

Post by peter_b »

Tar works fine with pipes, so here's a copy of commandline recipes by Mickaël Bergem:

Execute this on the host that will receive the data from the source server:

Code: Select all

$ ssh user@source-server "tar czpf - /some/important/data /some/other/file/or/folder" | tar xzpf - -C /backup/destination/folder
Tar-gzips the listed folders/files, outputs them to stdout over SSH, which is then received by the local "tar" command which is ungzipping and extracting the received contents in the /backup/destination/folder.

Here's a modified version which skips the (gzip-)compression part (e.g. for LAN):

Code: Select all

$ ssh user@source-server "tar -cpf - /home/user/whatever" > backup.tar
On Mickaël's blog there's also a recipe for pushing (this was pull).
Post Reply