by ktm5j · 8y ago · 0 comments
tar -cf - ./files.txt ./orDir/ | ssh host "(cd /dest/dir; tar -xf -)"
Given that ssh it so ubiquitous I think this will always be my go to.On the receiving end:
nc -vll 0.0.0.0 12345 | pv | tar xv
On the sending end: tar cv files... | pv | nc -N "destination IP" 12345
pv is a nice tool that just reports on the rate and number of bytes moving through the pipe, optional if you don't have it. Throw in gpg --symmetric + gpg --decrypt for good measure if you want to encrypt it on the wire with a password. scp file.txt user@host:/dest/dir/rsync -zvh file.txt user@host:/dest/dir/
So many ways to do this :)
rsync -n -avh --progress source destination:~/asdf/ for a dry run followed by ctrl-p, ctrl-a, alt-f, alt-d, alt-d to remove the -n flag and then execute that for the real thing.
Occasionally though, I'll also use sftp if I'm just pulling one thing - perhaps even after sshing to the remote machine.
For all of these, SSH keys should be set up (and desktop logins secured) to make life easier.
As for Android, adb push and adb pull -a seems to work better than mtp:// or AirDroid in my experience.
You should use '&&' instead of ';' on the host side. That way you don't accidentally dump your transfer contents into a wrong directory if the existing host dir doesn't exist.
e.g.: tar cf - stuff | ssh host "(cd /dest/dir && tar xf -)"
tar -C /dest/dir -xf - tar cf - src/ | ssh $host "tar -C /dest/dir -xf -":-D
> tar -cf - ./files.txt ./orDir/ | ssh host "(cd /dest/dir; tar -xf -)"
:-O
-h for human-readable numbers -a for archive mode -v and --progress for verbose info -z for compression during transfer
Add a -n for a dry run if required.
https://linux.die.net/man/1/rsync
One of the people who came up with it - Andrew Tridgell - was more or less "responsible" for Linux and BitKeeper parting ways, which in turn ultimately lead to the creation of Git. I think it's a fascinating story. Excellent tools.
The progress / speed display is the main thing that keeps me coming back to rsync even though other tools might manage the same job - not seeing the progress of a copy is what had me searching for that solution in the very first place.
--info=progress2
You can use it since rsync version 3.1.0.
Didn't know about nc or rysnc at the time. Good to see those other solutions, and good that there are many ways to do it, with different pros and cons.
@{cd fromdir && tar cp .} | @{cd todir && tar xT}