Syncing files across Ubuntu systems with rsync
Using rsync to sync files across Ubuntu systems is a practical way to move photos, documents, and project folders between a laptop, desktop, or home server. It compares the source and destination, then transfers changed data rather than recopying everything. A common Australian pattern is keeping a large photo archive on a NAS in Melbourne while family members work from laptops in Brisbane and Sydney, often over NBN broadband or a mobile hotspot.
This guide focuses on one-way transfers over SSH, the safest and most convenient method for home users. rsync can mirror changes, but it is not a live, two-way collaboration service. Plan the direction first, test with a dry run, and remember that deleting files with the wrong options can remove the only copy.
Prepare the two Ubuntu machines
On each system that will send or receive files, update its package lists and install rsync:
sudo apt update
sudo apt install rsync
Both machines need the program because rsync runs a copy of itself on the remote system. Confirm the installation with rsync --version. Ubuntu’s current releases provide a recent version with useful progress, exclusion, and partial-transfer options.
Choose a normal user account on the receiving machine. Using the recipient’s home directory is usually simpler than writing to /srv or another system location. Before transferring anything, check available space with df -h and make sure the destination filesystem supports the required permissions. exFAT and FAT-formatted drives cannot preserve all Unix ownership and permission details.
Decide whether the laptop will push files to the server or pull them back. The examples here push photos from a laptop to a NAS. To reverse the flow, simply exchange the source and destination paths. For adjacent Ubuntu administration topics, the publication offers practical Ubuntu articles that can support this workflow.
Create a secure remote connection
Use SSH to protect the transfer, including file names, directory structures, and personal documents. Generate a dedicated key on the sending machine and copy its public key to the server:
ssh-keygen -t ed25519 -C "ubuntu-nas"
ssh-copy-id ubuntu-backup@server-address
Give the private key a passphrase and keep the key in your home directory with permissions of 600. A password-protected key can still be used by scheduled jobs when its key is available through ssh-agent.
An SSH configuration file makes commands shorter and reduces typing errors. Create ~/.ssh/config and add an alias for the server:
Host ubuntu-nas
HostName 192.168.1.20
User ubuntu-backup
IdentityFile ~/.ssh/id_ed25519
Replace the example address with the server’s local IP address, public hostname, or VPN address. Test it with ssh ubuntu-nas. The same alias can then be used by rsync.
Do not run rsync as root or expose an unauthenticated rsync daemon to the internet. SSH already provides encryption and authentication, so only the SSH port needs to be reachable. Review authorised keys periodically, remove old entries, and use a dedicated account that has no unnecessary administrative privileges.
Google Drive, Microsoft OneDrive, and Dropbox are familiar choices in the Australian consumer and small-business market, but cloud storage may not suit files that must remain under your direct control or stay at a particular Australian location. A home NAS or VPS located in Australia can provide that control, subject to the provider’s terms and your organisation’s data-handling policy.
Define exactly what gets transferred
The following command sends the contents of Photos to the Photos directory in the remote account:
rsync -avz --info=progress2 --partial-dir=.rsync-partial \
"$HOME/Photos/" ubuntu-nas:/home/ubuntu-backup/Photos/
Archive mode (-a) preserves common attributes such as timestamps, permissions, and symbolic links. Verbose mode (-v) lists transferred files, while compression (-z) can reduce network traffic for documents and uncompressed files. The progress option provides a useful overall status for large transfers, and the partial directory keeps incomplete data so an interrupted transfer can resume more efficiently.
A trailing slash has an important effect. Photos/ means “the contents of this directory,” while Photos means “the directory itself.” Confusing the two can create an unwanted nested directory such as Photos/Photos. Quote paths containing spaces, and remember that shell variables such as $HOME are expanded by your local system before SSH opens the connection.
Exclusions prevent caches, temporary files, and other disposable content from being copied. For example, --exclude='.cache/' skips cache directories, while --exclude='*.tmp' skips temporary files. A reusable exclusion file can contain one pattern per line:
rsync -avz --exclude-from="$HOME/.rsync-exclude" \
"$HOME/Photos/" ubuntu-nas:/home/ubuntu-backup/Photos/
rsync normally transfers in one direction. It is well suited to backups and copies, but it does not intelligently merge edits made independently on both systems. If files may change in both places, use a tool designed for two-way synchronisation, such as Unison or Syncthing, and define how conflicting versions will be handled. The checksum option (-c) can detect changed content even when size and timestamps match, but it requires reading both versions and is expensive for large collections.
Test before copying real data
Use a dry run to see what rsync would do without changing the destination. Adding -n makes the command read-only, while --itemize-changes shows the planned actions:
rsync -avzn --delete --itemize-changes \
"$HOME/Photos/" ubuntu-nas:/home/ubuntu-backup/Photos/
Review each proposed deletion carefully. The --delete option makes the destination match the source by removing destination files that no longer exist in the source. Without that option, rsync leaves extra destination files untouched, which is usually safer during the first transfer.
Once the dry-run output looks correct, run the transfer without --delete:
rsync -avz --info=progress2 --partial-dir=.rsync-partial \
--itemize-changes \
"$HOME/Photos/" ubuntu-nas:/home/ubuntu-backup/Photos/
A slow connection can interrupt the operation. Rerunning the same command normally transfers only missing or changed data. Check the source and destination sizes with du -sh, and use a checksum-based dry run when you need stronger verification:
rsync -avnci "$HOME/Photos/" ubuntu-nas:/home/ubuntu-backup/Photos/
The exit status also matters: zero indicates success, while a non-zero value identifies an error that should be investigated. For a graphical workflow, people may find candidates in desktop download resources, but Ubuntu’s signed repositories or a developer’s verified release are safer places to obtain rsync and related administration tools.
Automate transfers without losing safety
A small script makes scheduled transfers predictable and easier to monitor. Save the following as ~/bin/sync-photos.sh:
#!/usr/bin/env bash
set -euo pipefail
rsync -az --info=progress2 --partial-dir=.rsync-partial \
--exclude='.cache/' \
-e 'ssh -o BatchMode=yes' \
"$HOME/Photos/" ubuntu-nas:/home/ubuntu-backup/Photos/
Make it executable with chmod +x ~/bin/sync-photos.sh. BatchMode=yes prevents a scheduled job from waiting for an interactive password prompt, so the SSH key must be available through the user’s agent or another protected automation method.
Create the log directory and add a cron entry with crontab -e:
mkdir -p "$HOME/.local/state"
30 2 * * * /home/ubuntu/bin/sync-photos.sh >> /home/ubuntu/.local/state/photos-sync.log 2>&1
Replace the example home path with your own. A systemd user timer is another option when you want stronger dependency handling. NBN upload speeds vary by plan, while connections in regional New South Wales or Queensland may be slower or less consistent than city connections. Partial transfers, sensible timeouts, and a retry policy make these variations easier to handle.
Deletion remains the main danger in unattended jobs. --delete-after removes stale destination files only after successful transfers, while --backup and --backup-dir retain versions of files that are about to be changed or removed. Snapshots on a Btrfs or ZFS filesystem provide another recovery layer. rsync is a synchronisation tool, not a complete backup strategy, especially if both systems contain the same files.
For Australian organisations, the Privacy Act 1988 and Australian Privacy Principles can make access controls, accurate records, and secure transfer methods part of ordinary governance. Under the mandatory notifiable-data-breach reforms, eligible incidents must be assessed and reported to affected people and the Office of the Australian Information Commissioner. SSH encryption, restricted accounts, key reviews, and reliable logs all help, but they do not replace endpoint security or separate backups. The rule to remember is simple: use SSH, begin with a dry run, control deletions carefully, and treat rsync as a dependable transfer tool rather than the sole guardian of your files.