2014-01-26 13:57:33 -06:00
# rsync
2023-08-07 05:40:39 +02:00
> Transfer files either to or from a remote host (but not between two remote hosts), by default using SSH.
2023-11-04 16:43:03 +00:00
> To specify a remote path, use `user@host:path/to/file_or_directory`.
2023-08-07 05:40:39 +02:00
> More information: <https://download.samba.org/pub/rsync/rsync.1>.
2014-01-26 13:57:33 -06:00
2023-08-07 05:40:39 +02:00
- Transfer a file:
2014-01-26 13:57:33 -06:00
2023-08-07 05:40:39 +02:00
`rsync {{path/to/source}} {{path/to/destination}}`
2014-01-26 13:57:33 -06:00
2023-11-04 16:43:03 +00:00
- Use archive mode (recursively copy directories, copy symlinks without resolving, and preserve permissions, ownership and modification times):
2014-01-26 13:57:33 -06:00
2025-03-07 13:25:35 +02:00
`rsync {{[-a|--archive]}} {{path/to/source}} {{path/to/destination}}`
2014-01-26 13:57:33 -06:00
2023-08-07 05:40:39 +02:00
- Compress the data as it is sent to the destination, display verbose and human-readable progress, and keep partially transferred files if interrupted:
2014-01-26 13:57:33 -06:00
2025-03-07 13:25:35 +02:00
`rsync {{[-zvhP|--compress --verbose --human-readable --partial --progress]}} {{path/to/source}} {{path/to/destination}}`
2014-01-26 13:57:33 -06:00
2023-08-07 05:40:39 +02:00
- Recursively copy directories:
2014-01-26 13:57:33 -06:00
2025-03-07 13:25:35 +02:00
`rsync {{[-r|--recursive]}} {{path/to/source}} {{path/to/destination}}`
2015-02-28 18:09:18 +00:00
2023-08-07 05:40:39 +02:00
- Transfer directory contents, but not the directory itself:
2019-02-11 14:49:40 +01:00
2025-03-07 13:25:35 +02:00
`rsync {{[-r|--recursive]}} {{path/to/source}}/ {{path/to/destination}}`
2019-02-11 14:49:40 +01:00
2024-06-03 10:44:03 +05:30
- Use archive mode, resolve symlinks, and skip files that are newer on the destination:
2015-12-30 01:40:29 +09:00
2025-03-07 13:25:35 +02:00
`rsync {{[-auL|--archive --update --copy-links]}} {{path/to/source}} {{path/to/destination}}`
2015-12-30 01:40:29 +09:00
2024-04-08 18:28:52 +04:00
- Transfer a directory from a remote host running `rsyncd` and delete files on the destination that do not exist on the source:
2015-02-28 18:09:18 +00:00
2025-03-07 13:25:35 +02:00
`rsync {{[-r|--recursive]}} --delete rsync://{{host}}:{{path/to/source}} {{path/to/destination}}`
2017-12-05 19:37:48 +01:00
2023-08-07 05:40:39 +02:00
- Transfer a file over SSH using a different port than the default (22) and show global progress:
2017-12-05 19:37:48 +01:00
2025-03-07 13:25:35 +02:00
`rsync {{[-e|--rsh]}} 'ssh -p {{port}}' --info=progress2 {{host}}:{{path/to/source}} {{path/to/destination}}`