How can I backup remotely the entire Linux server using rsync over SSH?

8,395

I can backup my Linux installation with exclusions using rsync command to my remote Rsync.net account or to any remote storage account through SSH with the following command

rsync -avzh --progress --delete --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/home/*,/lost+found,/backup/*} -e ssh /var [email protected]:remote_folder

Backups are incremental by default.

Parameters explained:

-a: archive mode (it keeps ownership, timestamp, permissions)

-v: verbose

-z: compress file data

-h: human-readable format

--delete: updates remote if files have been deleted from local

--progress: shows progress

rsync man page

Share:
8,395

Related videos on Youtube

Cadmos
Author by

Cadmos

Yolo

Updated on September 18, 2022

Comments

  • Cadmos
    Cadmos over 1 year

    I own a CentOS 6.9 box

    I need to backup remotely my entire CentOS installation to my Rsync.net storage account through SSH.

    How would that be possible including incremental updates and excluding system directories (like lost+found) that are useless for future transfer to other box ?

    • Ignacio Vazquez-Abrams
      Ignacio Vazquez-Abrams almost 6 years
      Excluding /home? That's a little...
    • ivanivan
      ivanivan almost 6 years
      Different parts of your system need different backup proceedures. For example, after initial configuration, /etc and subdirs and content rarely change. Your data files (users homes, maildirs, etc) change constantly. I'd split your backup process into multiples and use appropriate for each...
    • Cadmos
      Cadmos almost 6 years
      I agree but this does not answer the question, even partially on how to do it using rsync over ssh with exclusions
  • Alessandro Dotti Contra
    Alessandro Dotti Contra almost 6 years
    So, if I understand it correctly, you are missing the incremental part... that's why I'm suggesting you rsnapshot.
  • Cadmos
    Cadmos almost 6 years
    rsync does incremental backup by default, so no, I would not miss it :) .. anyway your answer was only a suggestion for something different instead of an answer to my question.
  • frakman1
    frakman1 almost 4 years
    So in this example, you are backing up the local /var folder to the remote? If so, then why all the excludes for other folders that aren't being copied? What does -e do?