Skip to content

Instantly share code, notes, and snippets.

@adzhurinskij
Last active December 16, 2023 07:26
Show Gist options
  • Save adzhurinskij/d0a7e95a692ae1ea84067588e799b5f0 to your computer and use it in GitHub Desktop.
Save adzhurinskij/d0a7e95a692ae1ea84067588e799b5f0 to your computer and use it in GitHub Desktop.
The fastest sync directory over ssh with tar

The fastest sync directory over ssh with tar

It's simple command for transfer a large number of small files over ssh.

You need to first go to directory, if you want to copy content of directory.

cd /var/www
tar cpf - ./ | ssh <user>@<dest_ip> "tar xpf - -C /var/www"

Preview speed copy with pv:

tar cpf - ./ | pv | ssh <user>@<dest_ip> "tar xpf - -C /var/www"

Method using rsync - https://gist.github.com/KartikTalwar/4393116

#!/bin/bash
cd /var/www
tar cpf - ./ | ssh <user>@<dest_ip> "tar xpf - -C /var/www"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment