On this page 27 sections
  1. What rsync does
  2. The most useful option: -a
  3. Verbose output
  4. Understand the trailing slash
  5. Show transfer progress
  6. Dry run before copying
  7. Synchronize through SSH
  8. Use a custom SSH port
  9. Use an SSH private key
  10. Exclude files and directories
  11. Include only specific files
  12. Delete files that no longer exist in source
  13. Resume interrupted transfers
  14. Human-readable sizes
  15. Compression during transfer
  16. Limit bandwidth
  17. Compare files using checksums
  18. rsync daemon mode
  19. List files inside a remote module
  20. Download from an rsync module
  21. Recursive module inspection
  22. Interesting CTF files
  23. Check TCP port 873
  24. rsync over SSH versus rsync daemon
  25. Useful local backup command
  26. Useful remote transfer command
  27. Useful CTF enumeration workflow
01

What rsync does

rsync synchronizes files and directories locally or between systems. It only transfers differences when possible, making it efficient for backups, deployments and remote file transfers.

Basic syntax
rsync SOURCE DESTINATION
02

The most useful option: -a

Archive mode (-a) recursively copies directories while preserving common metadata such as permissions, timestamps and symbolic links. It is the most common starting point for rsync operations.

Copy directory
rsync -a source/ destination/
03

Verbose output

-v shows which files are being processed. It is commonly combined with archive mode.

Archive and verbose
rsync -av source/ destination/
04

Understand the trailing slash

The trailing slash on the source changes what rsync copies. source/ means copy the contents of the directory, while source means copy the directory itself.

Copy directory contents
rsync -av source/ destination/
Copy directory itself
rsync -av source destination/
05

Show transfer progress

--progress displays transfer progress for individual files. --info=progress2 provides an overall progress view for the transfer.

Per-file progress
rsync -av --progress source/ destination/
Overall progress
rsync -av --info=progress2 source/ destination/
06

Dry run before copying

--dry-run shows what rsync would change without actually modifying files. It is especially useful before destructive synchronization operations.

Preview synchronization
rsync -av --dry-run source/ destination/
07

Synchronize through SSH

rsync commonly uses SSH for encrypted remote transfers. The remote destination follows the user@host:path format.

Upload to remote host
rsync -av source/ user@192.168.1.10:/home/user/backup/
Download from remote host
rsync -av user@192.168.1.10:/var/www/ ./www/
08

Use a custom SSH port

The -e option allows the SSH command used by rsync to be customised.

SSH on port 2222
rsync -av -e "ssh -p 2222" source/ user@192.168.1.10:/backup/
09

Use an SSH private key

A specific SSH private key can be selected through the SSH command passed with -e.

Transfer using private key
rsync -av -e "ssh -i id_rsa" source/ user@192.168.1.10:/backup/
10

Exclude files and directories

--exclude prevents selected files or directories from being transferred.

Exclude logs
rsync -av --exclude="*.log" source/ destination/
Exclude directory
rsync -av --exclude="cache/" source/ destination/
Multiple exclusions
rsync -av --exclude="*.log" --exclude="tmp/" source/ destination/
11

Include only specific files

--include and --exclude can be combined to restrict synchronization to selected file patterns.

Copy only TXT files
rsync -av --include="*/" --include="*.txt" --exclude="*" source/ destination/
12

Delete files that no longer exist in source

--delete removes destination files that are absent from the source. This creates a closer mirror but can destroy data if the source or destination is wrong. Always consider a dry run first.

Preview mirror
rsync -av --delete --dry-run source/ destination/
Mirror directory
rsync -av --delete source/ destination/
13

Resume interrupted transfers

--partial keeps partially transferred files instead of deleting them when a transfer is interrupted.

Keep partial transfers
rsync -av --partial --progress source/ destination/
14

Human-readable sizes

-h displays file sizes in a more readable format.

Readable output
rsync -avh --progress source/ destination/
15

Compression during transfer

-z compresses file data while it is being transferred. It can help on slower links but may provide little benefit for files that are already compressed.

Compressed remote transfer
rsync -avz source/ user@192.168.1.10:/backup/
16

Limit bandwidth

--bwlimit limits transfer bandwidth in KiB per second and can prevent rsync from consuming an entire connection.

Limit to approximately 1 MiB/s
rsync -av --bwlimit=1024 source/ destination/
17

Compare files using checksums

Normally rsync determines whether files changed using size and modification time. -c forces checksum comparison, which is more thorough but consumes additional CPU and disk I/O.

Checksum comparison
rsync -avc source/ destination/
18

rsync daemon mode

rsync can also run as a network daemon, commonly on TCP port 873. In daemon mode, directories are exposed as named modules instead of using SSH paths.

List modules on authorised server
rsync rsync://192.168.1.10/
Alternative syntax
rsync 192.168.1.10::
19

List files inside a remote module

If a module permits listing, its contents can be viewed without downloading anything.

List module
rsync rsync://192.168.1.10/backups/
Alternative module syntax
rsync 192.168.1.10::backups
20

Download from an rsync module

In authorised CTF or lab environments, a readable module can be copied locally for offline inspection.

Download module
rsync -av rsync://192.168.1.10/backups/ ./backups/
Alternative syntax
rsync -av 192.168.1.10::backups/ ./backups/
21

Recursive module inspection

A recursive listing is useful before downloading a large module because it shows its directory structure and potentially interesting filenames.

Recursive listing
rsync -r rsync://192.168.1.10/backups/
22

Interesting CTF files

When a readable rsync module is exposed in a lab, configuration files, backups, SSH material, scripts and application files are usually more interesting than blindly downloading everything.

List module first
rsync -r rsync://192.168.1.10/files/
23

Check TCP port 873

The traditional rsync daemon listens on TCP port 873. An open port does not automatically mean anonymous access is permitted, but it indicates that rsync daemon enumeration may be relevant.

Nmap service detection
nmap -sV -p 873 192.168.1.10
24

rsync over SSH versus rsync daemon

user@host:/path normally indicates rsync transported through SSH, usually using TCP 22. host::module or rsync://host/module refers to rsync daemon mode, commonly using TCP 873.

SSH transport
rsync -av user@host:/remote/path/ ./local/
Daemon module
rsync -av rsync://host/module/ ./local/
25

Useful local backup command

For many everyday backup tasks, archive mode, human-readable output and progress provide a good combination.

Practical backup
rsync -avh --info=progress2 source/ backup/
26

Useful remote transfer command

For SSH-based synchronization, archive mode together with progress gives a simple and reliable starting point.

Practical SSH transfer
rsync -avh --info=progress2 source/ user@host:/destination/
27

Useful CTF enumeration workflow

In an authorised lab, first identify whether TCP 873 is exposed, list available modules, inspect a relevant module recursively and only then copy interesting data locally.

1 — Identify service
nmap -sV -p 873 TARGET
2 — List modules
rsync rsync://TARGET/
3 — Inspect module
rsync -r rsync://TARGET/MODULE/
4 — Download readable module
rsync -av rsync://TARGET/MODULE/ ./MODULE/