Last active
February 17, 2021 00:30
-
-
Save frankyonnetti/936f83770add4f4405844e415a3cd8d1 to your computer and use it in GitHub Desktop.
rsync #rsync
This file contains hidden or 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
| # rsync basic | |
| rsync -a /tmp/foo/* /tmp/bar | |
| # NOTE: the difference between including a forward slash (/) at the end of the source path, and omitting it. | |
| foo/ # will transfer all files INSIDE the specified directory | |
| foo # will transfer the directory itself with all files inside | |
| # rsync file count | |
| rsyn -avz file/path/ file/path/ | wc -l | |
| # rsync files down from server | |
| # NOTE: by default, rsync only copies new or changed files from a source to destination. | |
| rsync -auv --delete --exclude=site_files deploy@h8.designhammer.com:/var/www/devhammer.com/prod/www/dh/ /Users/frankyonnetti/Desktop/testdir | |
| # alternative way to --exclude multiple files/dir is to list the files and directories in curly braces {} separated by a comma: | |
| rsync -a --exclude={'file1.txt','dir1/*','dir2'} src_directory/ dst_directory/ | |
| # flags | |
| -a # Archive | |
| # The -a (–archive) flag is an alias to a collection of other flags, -rltpgoD | |
| -r # Recursive | |
| -l # Transfer any symlinks encountered | |
| -t # Preserve time stamps | |
| -p # Preserve permissions | |
| -g # Preserve groups | |
| -o # Preserve ownership | |
| -D # Preserve block and character devices | |
| # other | |
| -h # Human-readable format of file sizes | |
| -z # Compress | |
| -v # Verbose | |
| -n # Dry run | |
| -u # allows rsync to skip files that are newer in the destination directory | |
| --delete # removes files and data from the destination directory. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment