-a, --archive
This is equivalent to -rlptgoD. It is a quick way of saying you want recursion and want to
preserve almost everything (with -H being a notable omission). The only exception to the above
equivalence is when --files-from is specified, in which case -r is not implied.
Note that -a does not preserve hardlinks, because finding multiply-linked files is expensive. You
must separately specify -H.
|
-m, --prune-empty-dirs
This option tells the receiving rsync to get rid of empty directories from the file-list,
including nested directories that have no non-directory children. This is useful for avoiding the
creation of a bunch of useless directories when the sending rsync is recursively scanning a
hierarchy of files using include/exclude/filter rules.
Note that the use of transfer rules, such as the --min-size option, does not affect what goes into
the file list, and thus does not leave directories empty, even if none of the files in a directory
match the transfer rule.
Because the file-list is actually being pruned, this option also affects what directories get
deleted when a delete is active. However, keep in mind that excluded files and directories can
prevent existing items from being deleted due to an exclude both hiding source files and
protecting destination files. See the perishable filter-rule option for how to avoid this.
You can prevent the pruning of certain empty directories from the file-list by using a global
"protect" filter. For instance, this option would ensure that the directory "emptydir" was kept
in the file-list:
--filter ’protect emptydir/’
Here’s an example that copies all .pdf files in a hierarchy, only creating the necessary
destination directories to hold the .pdf files, and ensures that any superfluous files and
directories in the destination are removed (note the hide filter of non-directories being used
instead of an exclude):
rsync -avm --del --include=’*.pdf’ -f ’hide,! */’ src/ dest
If you didn’t want to remove superfluous destination files, the more time-honored options of
"--include='*/' --exclude='*'" would work fine in place of the hide-filter (if that is more
natural to you).
|