Last active
July 8, 2021 06:41
-
-
Save 02Tea/c77eb828da0b51a92dfaa0bfa332ad3e to your computer and use it in GitHub Desktop.
[rsync remote to local vice versa] #rsync #bash #migrate #pv #progress #ssh
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
# Local to Remote: rsync [OPTION]... -e ssh [SRC]... [USER@]HOST:DEST | |
# Remote to Local: rsync [OPTION]... -e ssh [USER@]HOST:SRC... [DEST] | |
# remote -> local | |
rsync -havz -e ssh user@12.12.12.12:/var/wwww/livesite/ /var/www/localsite/ | |
# local -> remote | |
rsync -havz -e ssh /var/www/localsite/ user@12.12.12.12:/var/www/livesite/ | |
# dry run | |
rsync -hanvz -e ssh user@12.12.12.12:/var/wwww/livesite/ /var/www/localsite/ | |
# with key | |
rsync -hanvz --progress -e "ssh -i ~/.ssh/your_rsa" user@12.12.12.12:/var/wwww/livesite/ /var/www/localsite/ | |
# piped to pv (with progress bar) | |
# So if you have 42 files in /tmp/software and you would like to copy them to /nas10, enter: | |
rsync -vrltD --stats --human-readable /tmp/software /nas10 | pv -lep -s 42 | |
# or | |
rsync -vrltD --stats --human-readable /tmp/software /nas10 | pv -lep -s 42 >/dev/null | |
# built in progress bar remote -> local transfer | |
rsync -hav --progress user@12.12.12.12:/path/to/your/file.gz . | |
# rsync interprets a directory with no trailing slash as copy this directory, and a directory with a trailing slash as copy the contents of this directory. @source https://stackoverflow.com/questions/20300971/rsync-copy-directory-contents-but-not-directory-itself | |
# copies contents of foo/ | |
rsync -av ~/foo/ user@remote.com:/var/www/bar/ | |
# copies the foo directory | |
rsync -av ~/foo user@remote.com:/var/www/bar/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment