The Linux Experience XYZ

The Linux Experience XYZ

Musings on open source, Linux and related technologies by Tom Furnari.

Sync your Linux system files with rsync

rsync is a powerful command line utility to protect your data

Tom Furnari

4 minute read

This video takes a look at the using rsync to back up your system. (The video is embedded after the article below.)

Rsync, or Remote Sync, is a command-line tool that transfers files and directories to local and remote destinations. Rsync is used for mirroring, performing backups, or migrating data to other servers.

This tool is fast and efficient, copying only the changes from the source and offering customization options.

The scripts referenced on this page are available for download on my Gitlab page.

The basic command

The basic command to backup your home dir is:

rsync -aAvxXPn --exclude-from=/path/to/rsync.system.exclude.list --delete / /external/drive/destination/

Be sure to change /path/to/rsync.system.exclude.list to where you placed the rsync_ignore list file;

Be sure to change /path/to/your/external/drive/destination/ to where you would like the destination of your synced files to be. Note the destination directory must have a trailing slash to function as expected.

Command line options

I’ve used the following options:

Archive

-a, --archive

This is an important catch-all flag that includes the following options:

`-r, --recursive` recurse into directories

`-l, --links` copy symlinks as symlinks

`-p, --perms` preserve permissions

`-t, --times` preserve modification times

`-g, --group` preserve group

`-o, --owner` preserve owner (super-user only)

`-D` same as `--devices --specials`

`--devices` preserve device files (super-user only)

`--specials` preserve special files

It excludes:

`-H, --hard-links` preserve hard links

`-A, --acls` preserve ACLs (implies -p)

`-X, --xattrs` preserve extended attributes

Linux Access Control Lists

‘-A –acls’

This option preserves ACLs (implies –perms). ACLs allow the application of a more specific set of permissions to a file or directory without (necessarily) changing the base ownership and permissions.

Verbose

-v --verbose

This option increases the amount of information you are given during the transfer.

One file system

-x, --one-file-system

This tells rsync to avoid crossing a file system boundary when recursing. So basically, it will not follow other mount points to other file systems or partitions.

Partial and progress

-P, --partial --progress

The -P option is equivalent to --partial and --progress:

--partial Keeps a partial file. --progress Shows the progress of the transfer.

Delete

--delete

Deletes files in the destination directory if they don’t exist in the source directory.

Dry run

-n, --dry-run

Perform a trial run with no changes made. This option is not included above, though it can be added esially enough. The rsync.home.dryrun.sh file includes it.

Exclude file

--exclude-from=FILE

The command utilizes --exclude-from=/path/to/rsync.system.exclude.list to read a list of directories from the rsync.system.exclude.list file.

This file lists each directory you would like to exclude on a separate line. You may comment and uncomment any line at will; and if an entry does not correspond to an existing directory, it will skip it and will not fail. When backing up your system, it is strongly recommended that you end each entry with a trailing slash and an asterisk.

The --exclude=PATTERN option can be passed to rsync on the command line, but I have found this to be less reliable than the exclude-file method. It is recommended.

Timeshift

Timeshift

Timeshift for Linux protects your system by taking incremental snapshots of the file system at regular intervals. These snapshots can be restored at a later date to undo all changes to the system.

In RSYNC mode, snapshots are taken using rsync and hard-links. Common files are shared between snapshots which saves disk space. Each snapshot is a full system backup that can be browsed with a file manager.

Timeshift is similar to applications like rsnapshot, BackInTime and TimeVault but with different goals. It is designed to protect only system files and settings. User files such as documents, pictures and music are excluded. This ensures that your files remains unchanged when you restore your system to an earlier date.

Video

Please see the video below where I go through these topics in detail.

You may view it on YouTube or LBRY

If you found this video useful, please like and subscribe!

Like and subscribe!

Patrons enjoy exclusive benefits for regular contributions:

Become a Patron!

Or, a one time donation is also very much appreciated:

PayPal.me

Say something

Comments

Nothing yet.

Recent posts

Categories

About

The Linux Experience XYZ is dedicated to exploring our favorite operating system: Linux