Rsync backup media

To copy a directory from one directory to another, they command line would be:

rsync -options --otherOptions sourceDir targetDir

Example 1: rsync -vaz ~/jump/Music/ ~/Media/Music

This example copies the contents of the /jump/Music/ directory to the /media/Music directory.

Take Note of the ending back slash.

(2022-01-07) On NAS rsync -vaz volumeUSB1/usbshare/Scanned/ volume1/music

This command can be used to synchronize a folder, and also resume copying when it's aborted half way. The command to copy one disk is:

rsync -avxHAX --progress / /new-disk/

The options are: -a : all files, with permissions, etc..
-v : verbose, mention files
-x : stay on one file system
-H : preserve hard links (not included with -a)
-A : preserve ACLs/permissions (not included with -a)
-X : preserve extended attributes (not included with -a)

To improve the copy speed, add -W (--whole-file), to avoid calculating deltas/diffs of the files. This is the default when both the source and destination are specified as local paths, since the real benefit of rsync's delta-transfer algorithm is reducing network usage.

Also consider adding --numeric-ids to avoid mapping uid/gid values by user/group name.

Compare the size of two directories. diff <(du -sh dir1) <(du -sh dir2)

Copying kzone os to new drive

rsync -gloptrv --exclude={/dev/,/proc/,/sys/,/tmp/,/run/,/mnt/,/media/,/Downloads/,/Dropbox/,radio/,/podcasts/,/jump/,/skip/*,/lost+found} /mnt/g entoo/ /jump/HD-KZONE/

rsync -gloptrunc srcdir dstdir A brief guide:

g - preserve group ownership info

l - copy symlinks as symlinks o - preserve owner info p - preserve permissions t - preserve timestamps r - recurse thru directories u - update, skip any newer files [n] - no, dont do this, do a dry run instead c - checksum, attempt checksums on file blocks when possible (*) note: on local filesystems, this get overridden and entire files are copied instead. v - verbose

I always run the above to make sure it works, then remove the 'n' flag that once I'm happy with the results