0

I use sudo rsync --archive --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*",/lost+found} a lot for backups so I want to be sure of what it does.

According to the rsync man page, --archive or -a is equivalent to -rlptgoD. All this options are fine and clear for me, except -D equivalent to --devices --specials, that are explained in Unix files types, Wikipedia.

I have never seen the effect of -D, copying device and special files is completely out of my present understanding.

In which case could -D be useful for archiving?

Should I just write -rlptgo(no -D) to prevent unexpected effects?

While writing this, I have the idea that sudo rsync --archive --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*",/lost+found} could be replaced by sudo rsync -rlptgo, because devices and specials are roughly covered by the exclude; in particular, devices are exactly "/dev/*".

  • You could create special device files like /dev/zero pretty much wherever you want using mknod: https://unix.stackexchange.com/q/562341/70524 (You probably may not have, but when making a whole system backup, it's worth considering that something you use may have) – muru Apr 22 '21 at 06:03
  • That is an interesting example: compare sudo rsync /dev/zero toto and sudo -D rsync /dev/zero toto and cp /dev/zero toto. rsync -D transfers /dev/zero nicely whereas cp fills the target with zeros. – Pierre ALBARÈDE Apr 22 '21 at 19:43
  • I am still looking for a case when -D would be dangerous. – Pierre ALBARÈDE Apr 22 '21 at 19:47
  • 1
    You could use rsync -a --no-D ... – Chris Davies Apr 22 '21 at 19:54
  • 1
    @PierreALBARÈDE Regarding your most recent comment here, it's rather the other way around; You want to use -D, because not using -D could have unwanted consequences if you are copying directories containing device files, as you yourself noticed in the other comment. – Kusalananda Apr 22 '21 at 20:59

0 Answers0