Last active
December 19, 2015 08:59
-
-
Save gsouf/5929238 to your computer and use it in GitHub Desktop.
rsyn over ssh and scp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# COPY DIRECTORY /source/dir FROM myhost to /destination/dir on the localhost WITH THE SSH SHELL | |
rsync -avz -e "ssh" user@myhost:/source/dir /destination/dir | |
### OPTIONS | |
# -a for archive mode (recursive, copys symlink, copys permissions, copys update times, preserves owner) | |
# -v for verbose (writes what it does) | |
# -z for compress while transfering | |
# SAME BUT WE EXCLUDE SOME FILES/DIR | |
rsync -avz -e "ssh" \ | |
--exclude "/adir/afile" \ | |
--exclude "secret.*" | |
--exclude "anotherdir" \ | |
user@myhost:/source/dir /destination/dir | |
# SAME BUT WE INCLUDE ONLY A FEW FILES | |
rsync -avz -e "ssh" \ | |
--exclude "*" \ | |
--include "onedir" \ | |
--include "patern.*" \ | |
user@myhost:/source/dir /destination/dir | |
# SAME BUT ON A CUSTOM (non default) SSH PORT | |
rsync -avz -e "ssh -p 12121" user@myhost:/source/dir /destination/dir | |
# WE CAN ALSO USE SCP TO COPY RECURSIVELY A DIRECTORY | |
scp -r /source/dir user@myhost:/destination/dir -P22 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment