266

I know you can use -a or --archive to activate archive mode when using rsync. Unfortunately, I have no idea what archive mode is supposed to do, and the man page is not at all explicit about what this is:

equals -rlptgoD (no -H,-A,-X)

Can you explain what those options (rlptgoD) mean and what's the behaviour of rsync when I use them?

1

3 Answers 3

331

It's all of these:

-r, --recursive recurse into directories

-l, --links copy symlinks as symlinks

-p, --perms preserve 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

It excludes:

-H, --hard-links preserve hard links

-A, --acls preserve ACLs (implies -p)

-X, --xattrs preserve extended attributes

It's perfect for backups. My "default" set of switches is -avzP - archive mode, be verbose, use compression, preserve partial files, display progress.

Note: Invariably when the descriptions say "preserve", it means make the destination be like the source.

11
  • 60
    +1 - yes, it's in the man page, but it's also nice to see it here with the answer for easy reference
    – cwd
    Dec 21, 2014 at 5:43
  • 6
    easier than looking in the man page :P ?
    – Salami
    Oct 12, 2015 at 5:39
  • 1
    +1 for sharing the option combination for backups (-avzP).
    – RoboAlex
    Mar 3, 2016 at 5:48
  • 3
    yeah somewhere along the way, lmgtfy became easier than man rsync.
    – Stu
    Mar 17, 2016 at 13:40
  • 2
    @xealits According to the man page, The -P option is equivalent to --partial --progress.
    – Sutandiono
    May 11, 2017 at 7:42
24

It make sure the permission, attributes, etc. is same at the both side. rsync only works in that way... if you want to synchronising files, you have to use -a parameter.

This is because rsync compare these permission, attribute, etc. at both side to determining if they are the SAME FILE and decide if it should be updated. if you use rsync -r xxx yyy instead rsync -a xxx yyy, some files will be copy again and again, coz, permission, attribute not be synchronised, and miss matched at both side...

18

The archive switch is just a shortcut to skip having to enter a bunch of switches that you'll normally use if you're using rsync to make backups (a common task).

It's the same as typing:

rsync -r -l -p -t -g -o -D

And it's much easier to remember. You can find definitions for all of those switches in the man page.

(The hyphens are optional when you're combining multiple single-letter switches.)

3
  • 14
    thanks, but I think you're missing my point. Can you please explain what combining all those options does without having me read 7 different parts of the man page, which probably refer to other parts of the man page? May 14, 2010 at 3:40
  • 18
    I think you're missing the point that it's important to read the man page to know exactly what you're doing. rsync has some very powerful options, including a way to delete files! It's like your asking for help on using a table saw because you don't like reading instruction manuals.
    – David M
    May 14, 2010 at 3:53
  • 4
    Of course, I just don't like reading the instruction manual for the 100th time when I can instead refer to a cheatsheet.
    – CivFan
    Aug 8, 2017 at 16:55

You must log in to answer this question.

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