如果我使用命令
rsync -av / /媒体/备份
/media/back 是否包含在 / 文件系统中?这是否会导致某种重复循环,从而导致 rsync 尝试将 /media/backup 复制到自身?
答案1
你需要--exclude
它。
sudo rsync -a --exclude=/media/backup / /media/backup
你可能不需要删除选项,但我已将其和下面其他一些选项包括在内,以防万一。请注意-rlptgoD
=-a
sudo rsync --dry-run -hv --progress --stats -rlptgoD \
--exclude=/media/backup \
--delete \
/ /media/backup
# A summary of most of the Options used above
# ===========================================
# --dry-run For tesing your command. Remove it
# when you are satisfied with the command.
# -hv Human Verbose
#
# -a, --archive Archive mode
# (-a == -rlptgoD # no -H,-A,-X)
# -r, --recursive Recurse into directories
# -l, --links Copy symlinks as symlinks
# -p, --perms This option causes the receiving rsync to set the destination
# permissions to be the same as the source 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
#
# --delete Delete extraneous files from dest dirs
#
# 'PATTERN (for 'exclude')
# ’*’ matches any path component, but it stops at slashes.
# ’**’ to match anything, including slashes.