Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .