Updated: 8 October 2026 · Applies to: rsync 3.4.1 (Ubuntu 26.04, tested), 3.2.7 (Ubuntu 24.04, AlmaLinux 9) and 3.5.x (Debian 13, AlmaLinux 10, Fedora 44)
rsync already copies only new and changed files: by default it skips any file whose size and modification time match the destination. So rsync -av source/ destination/ is the basic "sync new and changed files" command. To narrow it down further:
- Only new files (never touch files that already exist):
rsync -av --ignore-existing source/ destination/ - Only newer files (do not overwrite a file that is newer on the destination):
rsync -av --update source/ destination/(short:-u) - Only update files that already exist (create nothing new):
rsync -av --existing source/ destination/ - Test run first: add
-n(--dry-run) and-i(--itemize-changes) to see what would happen.
In -av, -a is archive mode (recursive, keeps permissions, times, owners and links) and -v lists each file.
Example: sync one directory to another
- Make the first copy. rsync only creates the last folder of the destination path, so if
/backupdoes not exist yet you get:rsync: [Receiver] mkdir "/backup/Documents" failed: No such file or directory (2)
Add--mkpath(or create the folder withmkdir -p):$ rsync -av --mkpath Documents/ /backup/Documents/ sending incremental file list created 2 directories for /backup/Documents ./ notes.txt report.txt
- After adding
new.txtand editingreport.txt, do a test run:$ rsync -avn --itemize-changes Documents/ /backup/Documents/ sending incremental file list .d..t...... ./ >f+++++++++ new.txt >f.st...... report.txt ... total size is 19 speedup is 0.12 (DRY RUN)
>f+++++++++means a new file will be copied;>f.st......means an existing file changed in size (s) and time (t).notes.txtis not listed because it has not changed. - Run it for real by dropping
-n. Only the two files are copied:$ rsync -av Documents/ /backup/Documents/ sending incremental file list ./ new.txt report.txt
Copy only new files: --ignore-existing
Here todo.txt was new and report.txt had changed again. Only the new file was copied:
$ rsync -av --ignore-existing Documents/ /backup/Documents/ sending incremental file list ./ todo.txt
Update only existing files: --existing
Now a new draft.txt exists in the source. --existing updated report.txt and did not create draft.txt:
$ rsync -av --existing Documents/ /backup/Documents/ sending incremental file list report.txt
Copy only newer files: --update
notes.txt was edited in the source and then edited again on the backup, so the backup copy is newer. Without -u rsync would overwrite it; with -u it is skipped:
$ rsync -avn Documents/ /backup/Documents/ sending incremental file list notes.txt ... $ rsync -avun Documents/ /backup/Documents/ sending incremental file list sent 163 bytes received 12 bytes 350.00 bytes/sec
Use -u when files may be edited on both sides. rsync compares modification times, so keep the clocks of both machines correct.
Trailing slash: contents or the folder itself
$ rsync -a Documents /backup/test1/ # creates /backup/test1/Documents $ rsync -a Documents/ /backup/test2/ # copies the contents into /backup/test2
Copy a single file, or log to a file
- Copy one file under a new name:
rsync -av Documents/report.txt /backup/report-copy.txt - Write what rsync did to a log file:
rsync -a --log-file=/root/rsync.log Documents/ /backup/Documents/. The log uses the same codes as-i, for example>f+++++++++ draft.txt.
Whole files instead of the delta algorithm: -W
-W (--whole-file) sends changed files completely instead of only the changed blocks. According to the rsync manual it is already the default when both source and destination are local paths, and it can be faster when the network is quicker than the disks.
Sync to or from a remote server over SSH
Use user@host: in front of the remote path. The same options work, and -e "ssh -p PORT" sets a non-standard SSH port (tested with port 2222):
$ rsync -avun --itemize-changes -e "ssh -p 2222" Documents/ root@127.0.0.1:/srv/backup/Documents/ sending incremental file list .d..t...... ./ <f.st...... a.txt <f+++++++++ c.txt
< means the file is sent to the remote side. Swap source and destination to pull files from the server. See also rsync with a non-standard SSH port and back up your files with rsync and a VPS.
Rsync from Linux to Windows
rsync must run on both ends, and Windows has no built-in rsync. The simplest route is WSL:
- In PowerShell as administrator run
wsl --installand restart; according to Microsoft this installs Ubuntu by default (see WSL on Windows 10 and 11). - In the Ubuntu window:
sudo apt install rsync - Pull from your Linux server into a Windows folder, which WSL shows under
/mnt/c:rsync -av --update user@server:/var/www/ /mnt/c/Backups/www/
Copying to a FAT-formatted USB drive? Add --modify-window=1: the rsync manual notes that FAT stores times with 2-second resolution, so a copied file's time can differ by a second and rsync would copy it again.
Rsync with a GUI
Grsync is a simple graphical front end for rsync. It covers a limited set of the most important options, which is enough for local folder syncs. Install it with sudo apt install grsync (Ubuntu, Linux Mint, Debian) or sudo dnf install grsync (Fedora). Ubuntu 26.04 ships Grsync 1.3.1.
More options: 13 rsync command examples for Linux. Official documentation: rsync manual page.
Ucartz services for this topic
- KVM VPS hosting: NVMe SSD and full root access, with Free Basic Managed Support.
- Unmanaged dedicated servers: full root access and free IPMI KVM, with Free Basic Managed Support.
- Linux server management: hardening, patching, monitoring and automation for Ubuntu, Debian, RHEL and AlmaLinux.
