Last active
February 21, 2024 04:09
-
-
Save brunopk/37c9703b9bc82061d32303d99d29d9fb to your computer and use it in GitHub Desktop.
Useful commands for Linux and macOS
For all the examples below, asume there exist src (source) and dest (destination) folders.
rsync --recursive --delete src dest
--delete
: to delete files/folders which exist in dest/ but don't exist in src/
rsync --recursive --delete src/ dest
Same as 1 but without creating dest/src/ folder (just copying src content to dest):
$ rsync -aP --delete src/ dest
-a
: archive mode, which is necessary for rsync to identify modified files requiring copying.
-P
: show progress.
Over SSH and using custom keys ($HOME/.ssh/somekey):
rsync -Pav -e "ssh -i $HOME/.ssh/somekey" username@hostname:/from/dir/ /to/dir/
-P
: show progress.
-v
: verbosity.
rsync --recursive \
--progress \
--archive \
--exclude-from=.gitignore \
--exclude=.git \
--exclude=.gitignore \
folder user@ipaddress:~/dest/
Similar to previous examples to copy over SSH.
--exclude-from
: receives a file path with a format similar to CVS ignore files, such as the .gitignore file in Git, to indicate which files and directories should be excluded.
--exclude
: indicates a folder or file to exclude.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment