Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

If I use the command

rsync -av / /media/backup

Is /media/back included in the / filesystem? Would that cause some kind of repeating loop causing rsync to attempt to copy /media/backup to itself?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

You need to --exclude it.

sudo rsync -a --exclude=/media/backup  /  /media/backup

You may not need the delete option, but I've included it and some others below, in case you do. Note that -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.
share|improve this answer
    
Thanks for you help! –  dedwarmo Feb 10 '13 at 16:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.