← Volver al blog

How to Install and Use rsync for Backups

  • Xernode
  • 1 min de lectura
  • 3 de abril de 2026
Linux backup rsync linux server synchronization

Introduction

rsync is a powerful and efficient tool for backing up and synchronizing files and directories in Linux. This guide shows you how to install rsync and use it for local and remote backups.

Step-by-step Guide

  1. Install rsync
    • sudo apt update
    • sudo apt install rsync
  2. Basic local backup with rsync
    • rsync -avh /source/directory/ /destination/directory/n
      • (Replace /source/directory/ and /destination/directory/ with your actual paths)
  3. Backup to a remote server via SSH
    • rsync -avh -e ssh /source/directory/ user@remote_ip:/remote/backup/directory/n
      • (Replace userremote_ip, and paths as needed)
  4. Restore files from backup
    • rsync -avh user@remote_ip:/remote/backup/directory/ /restore/location/
  5. (Optional) Exclude files or directories from backup
    • rsync -avh --exclude 'node_modules' /source/ user@remote_ip:/remote/backup/
  6. (Optional) Run rsync as a cron job for automatic backups
    • Edit your crontab:n
      • crontab -e
    • Add a line like:n
      • 0 3 * * * rsync -avh /source/ /destination/

Recommendations

  • Always test your backup and restore process before relying on it.
  • Use SSH keys for secure, passwordless remote backups.
  • Regularly monitor your backup logs for errors.

Call To Action

Looking for reliable storage for your backups? Try our VPS plans! https://xernode.com/#pricing

Related Guides