SysTutorials

How to Back Up Linux Home Directories with rsync

· updated April 12, 2026

rsync is a reliable choice for backing up your Linux home directory, especially when dealing with large files and incremental changes. Unlike git (which struggles with files >5GB), rsync efficiently handles large files and only transfers what’s changed on subsequent runs.

Basic Backup Command

The fundamental syntax is straightforward:

rsync -avxP \
  /path/to/directory/to/backup \
  /path/to/directory/for/storing/backup

Breaking down the flags:

Practical Example

To back up your home directory to an external drive mounted at /mnt/backup:

rsync -avxP ~/. /mnt/backup/home-backup/

Note the trailing slash on the source — this copies the contents of your home directory rather than the directory itself.

Handling Deletions

By default, rsync preserves files in the destination that no longer exist in the source. This is intentional safety behavior. If you want rsync to mirror the source exactly (deleting files from the backup if they’re removed from your home directory), add the --delete flag:

rsync -avxP --delete ~/. /mnt/backup/home-backup/

Use this carefully — it’s permanent.

Additional Useful Flags

Consider adding these flags depending on your needs:

rsync -avxP --delete --exclude='.cache' --exclude='.local/share/Trash' ~/. /mnt/backup/home-backup/

Remote Backups

rsync works seamlessly over SSH. To backup to a remote server:

rsync -avxP -e ssh ~/. user@remote-host:/backup/home-backup/

The -e ssh flag specifies SSH as the transport. Ensure SSH key authentication is configured for non-interactive backups.

Automating with cron

For regular backups, add a cron job. Create or edit crontab -e:

# Weekly backup every Sunday at 2 AM
0 2 * * 0 rsync -avxP --delete ~/. /mnt/backup/home-backup/ >> /var/log/rsync-backup.log 2>&1

Redirect output to a log file to monitor backup success. For sensitive operations, consider using --log-file instead:

rsync -avxP --delete --log-file=/var/log/rsync-backup.log ~/. /mnt/backup/home-backup/

Performance Tips

Permission and Ownership

If backing up as a non-root user, rsync preserves whatever permissions you can read. If files are owned by other users and you don’t have read access, rsync will skip them. For complete backups, run as root:

sudo rsync -avxP --delete ~/. /mnt/backup/home-backup/

However, be careful with sudo and rsync — always double-check your source and destination paths.

rsync is resilient and handles interrupted transfers gracefully. If a backup is interrupted, re-running the same command resumes where it left off, transferring only the remaining portions of incomplete files.

← All posts