Skip to main content

How to Use rsync for Backup on Linux: A Step-by-Step Guide

HardReset.InfoJanuary 1, 20267 min28 views
3 connections·5 entities in this video→

Getting Started with rsync

  • πŸ’‘ rsync is a powerful tool for backups on Linux, and it's likely installed by default.
  • πŸ’» To confirm, open your terminal and run rsync --version to check the installed version.

Setting Up Your Backup Environment

  • πŸ“ Create a directory for your data, for example, named data, and populate it with sample files like file1.txt and file2.txt.
  • πŸ—„οΈ Next, create a separate directory where your backups will be stored, named backup.

Performing Basic and Incremental Backups

  • πŸš€ A basic local backup can be initiated with rsync -av data/ backup/. The -a flag ensures archive mode (preserving permissions, owner, timestamps), and -v provides verbose output.
  • πŸ”„ For incremental backups, rsync intelligently copies only changed files. If you modify a file in the data directory (e.g., add a new line to file1.txt) and rerun the command, rsync will only transfer the updated file1.txt.

Advanced Backup Strategies: Mirroring and Dry Runs

  • πŸͺž A mirror backup synchronizes the source and destination, removing files from the backup directory if they are deleted from the source. Use the --delete flag: rsync -av --delete data/ backup/.
  • ⚠️ To safely preview changes before they are applied, use the --dry-run option. This command (rsync -av --delete --dry-run data/ backup/) will show you what would be deleted or copied without actually performing the actions, allowing you to verify your backup strategy.
Knowledge graph5 entities Β· 3 connections

How they connect

An interactive map of every person, idea, and reference from this conversation. Hover to trace connections, click to explore.

Hover Β· drag to explore
5 entities
Chapters3 moments

Key Moments

Transcript28 segments

Full Transcript

Topics9 themes

What’s Discussed

rsyncLinuxBackupIncremental BackupMirror BackupDry RunArchive ModeTerminalCommand Line
Smart Objects5 Β· 3 links
ProductsΒ· 2
ConceptsΒ· 2
LocationΒ· 1