I want to know how use rsync for sync to folders recursive but I only need to update the new files or the updated files (only the content not the owner, group or timestamp) and I want to delete the files that not exist in the source.

8 Answers 8


I think you can use the -no- options to rsync to NOT copy the ownership or permissions of the files you're sync'ing.

Excerpt From rsync Man Page

       You may turn off one or more implied options by prefixing the option 
       name with "no-".  Not all options may be pre‐fixed  with  a  "no-":  
       only options that are implied by other options (e.g. --no-D, 
       --no-perms) or have different defaults in various circumstances (e.g. 
       --no-whole-file, --no-blocking-io, --no-dirs).  You may specify 
       either the short or the long option name after the "no-" prefix (e.g. 
       --no-R is the same as --no-relative).

       For example: if you want to use -a (--archive) but don’t want -o 
       (--owner), instead of converting -a into -rlptgD, you could specify 
       -a --no-o (or -a --no-owner).

       The order of the options is important:  if you specify --no-r -a, the 
       -r option would end up being turned on,  the opposite  of  -a  
       --no-r.   Note  also  that the side-effects of the --files-from 
       option are NOT positional, as it affects the default state of several 
       options and slightly changes the meaning of -a (see the  --files-from
       option for more details).

Ownership & Permissions

Looking through the man page I believe you'd want to use something like this:

$ rsync -avz --no-perms --no-owner --no-group ...

To delete files that don't exist you can use the --delete switch:

$ rsync -avz --no-perms --no-owner --no-group --delete ....


As for the timestamp I don't see a way to keep this without altering how you'd do the comparison of SOURCE vs. DEST files. You might want to tell rsync to ignore timestamps using this switch:

-I, --ignore-times
       Normally  rsync will skip any files that are already the same size 
       and have the same modification timestamp.  This option turns off this 
       "quick check" behavior, causing all files to be updated.


For timestamps, --no-times might do what you're looking for.

  • 1
    when using --no-times I'm still seeing a lot of files (with itemized changes) marked using >f..T... which suggests fileflags and modification time are being set on the destination, which is what I'm trying to avoid.
    – Michael
    Dec 9, 2015 at 4:10
  • 1
    @Michael, agree, but if you add --size-only option, you will see (with itemized changes) your files marked like .f , i.e. rsync will run without any timestamp comparison. So the command like rsync -iirtv --no-times --size-only source_dir/ dest_dir/ is just what I need to backup from Mac to an external NTFS drive...
    – hooke
    Apr 8, 2020 at 11:38

I think it´s easier to avoid the -a option

$ -a, --archive               archive mode; equals -rlptgoD (no -H,-A,-X)

and set only the options do you want.

If you like all options but not the modifications of user -o, group -g, time -t and permissions -p so you could subtract these four options from the archive equivalent.

$ -rlD

To delete the files on destination please use option --delete.

To your question: But I think all files will be checked - rsync can´t transfer/check only files that changed only by content.

  • -l is for links, -D devices (treated same as --specials), I think -r alone is enough if we are talking content.
    – user80158
    Aug 3, 2018 at 7:38
  • For some reason when I used -a rsync was comparing checksums to sync only new/modified files. Using -rlD didn't use the checksum comparison, so I ended up using -rlDc. Hope it helps someone. Nov 30, 2020 at 11:04

I think what you are looking for is the option

rsync -r --size-only

from the man page:

   This  modifies  rsync’s  "quick  check" algorithm for finding files
   that  need  to  be  transferred,  changing  it  from the default of
   transferring  files   with  either  a  changed  size  or a  changed
   last-modified  time  to just looking for files that have changed in 
   size. This is useful when starting to use rsync after using another
   mirroring system which may not preserve timestamps exactly.

If you really want to delete files missing in the source dir, use --delete.


You can force rsync to ignore checks based on file mod time and size and use a chksum based approach with the "-c" switch.

-c, --checksum              skip based on checksum, not mod-time & size

This does mean that it needs to compare the entire file in chunks (and transfer the relevant metadata back and forth between source and destination for this to happen) regardless of whether or not file time and size match, but will only transfer the chunks that differ between the source and destination.

Using this switch in conjunction with the other switches suggested by others should limit what's copied (only copying that which has changed), and has the benefit of doing a consistency check between source and destination, BUT it does take longer depending on your link speed as it has to chksum the file chunks on both sides and compare).

  • I doubt that's what OP had in mind. The problem didn't appear to be related to how the files were selected but the attributes copied over, and the chosen (most upvoted too) answer already covers that. Aug 16, 2016 at 7:08

I ended up using:

rsync -rv --size-only /mnt/from/ /mnt/to/

My destination was a webdav mount, and this made the progress visible and the initial file check a lot faster.

This does not delete in the destination as I wasn't looking for that option for my use case.


We had a situation where rsync changes would result in things being reset further down the line, which was only desirable if the file contents had changed, not if they had just been touched.

It turned out that --ignore-times did not work for this scenario, but telling rsync to be much more lenient with regards to whether two timestamps were equal worked. Up to a difference of a billion seconds is around 31 years which is fine for our use.

rsync --archive --itemize-changes --modify-window=1000000000 --delete-after A B

(the --itemize-changes is to be able to count the changes, and skip if none)

  • What was the exact command that did not work (order of options matter), and what filesystems were involved (this matters since some may not support Unix metadata)? The fact that using --ignore-times failed but using --modify-window worked cold be due to ordering of the options relative to the --archive option, for example.
    – Kusalananda
    Nov 4, 2021 at 14:05
  • @they I had the -a first and I was just experimenting. Nov 4, 2021 at 14:19
  • @they this is from one directory to another on the same Linux machine. (Ext4 file system if that matters) Nov 5, 2021 at 9:40
  • In that case I really see no reason why --ignore-times did not work. The --modify-window is usually used when one of the filesystems have a much lower resolution of timestamps, like FAT vs. ext4.
    – Kusalananda
    Nov 5, 2021 at 9:42
  • @they I know. That is why I decided to add this as an answer as others may have our very specific use case. Nov 5, 2021 at 15:03

This is my working solution

rsync --delete -r --size-only --inplace --progress \
<SRC> /run/user/<UID>/gvfs/mtp\:host\=Xiaomi_Xiaomi_Pad_5_45hfd466/Internal\ shared\ storage/Download/_DIR/ \

Below command would work perfectly, I tested it for my own requirement, it will take only the content change.

rsync -acvzh source/ destination/

You must log in to answer this question.

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