Rsync

From David's Wiki
\( \newcommand{\P}[]{\unicode{xB6}} \newcommand{\AA}[]{\unicode{x212B}} \newcommand{\empty}[]{\emptyset} \newcommand{\O}[]{\emptyset} \newcommand{\Alpha}[]{Α} \newcommand{\Beta}[]{Β} \newcommand{\Epsilon}[]{Ε} \newcommand{\Iota}[]{Ι} \newcommand{\Kappa}[]{Κ} \newcommand{\Rho}[]{Ρ} \newcommand{\Tau}[]{Τ} \newcommand{\Zeta}[]{Ζ} \newcommand{\Mu}[]{\unicode{x039C}} \newcommand{\Chi}[]{Χ} \newcommand{\Eta}[]{\unicode{x0397}} \newcommand{\Nu}[]{\unicode{x039D}} \newcommand{\Omicron}[]{\unicode{x039F}} \DeclareMathOperator{\sgn}{sgn} \def\oiint{\mathop{\vcenter{\mathchoice{\huge\unicode{x222F}\,}{\unicode{x222F}}{\unicode{x222F}}{\unicode{x222F}}}\,}\nolimits} \def\oiiint{\mathop{\vcenter{\mathchoice{\huge\unicode{x2230}\,}{\unicode{x2230}}{\unicode{x2230}}{\unicode{x2230}}}\,}\nolimits} \)

See Archwiki:rsync and rsync(1) - Linux man page

System Backups

  • Create a script and add it to your crontab -e

Basic Backup

#!/bin/bash

TARGET_FOLDER=<your target for backup>
EXCLUSIONS='--exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"}'

sudo rsync -aAXq ${EXCLUSIONS} / "${TARGET_FOLDER}"
Flags
  • -a archive mode
  • -A preserve ACLs (access control lists)
  • -X preserve extended attributes
  • -q quiet

Exclude

Add --exclude to your call.

Notes
  • Exclude typically uses a pattern. If you want to exclude from the root of the transfer, prepend /.
    E.g
    rclone --exclude "/project/node_modules" project /some/other/dir/
  • Add --exclude before --stats and --delete if you want it to work.

You can also use --exclude-from and point to a text file list of exclusions.