Compare rsync backup times with USB drive and SATA drive

I personally always ‘cd’ to the parent of source directory for rsync/tar, and do the rsync/tar on “./src”.
For cp, I don’t do any ‘cd’, as it is clear enough for me: I see no difference between ‘cp ~/file /tmp’ and ‘cp -r ~/dir /tmp’. In both cases, the last component of source will be copied to /tmp, ‘as is’.

  • rsync, scp and cp are copy tools, they copy last component of ‘src’ to ‘dst’ (with the rsync trailing ‘/’ exception).
  • tar is an archive program (like cpio), so it will write or read an archive file. The archive file has to contain the full ‘src’ tree information.

Some additional remarks:

About rsync, it will prepend the last directory component if source does not has a trailing ‘/’. Otherwise, ‘src’ last component is still part of the copy (but considered as dst itself), meaning that attributes (access, ownership, etc…) will be applied to dst itself.

# if ./src contains only 'foo' file :
$ rsync -avH ./src  host:dst/dir    # -> dst/dir/src/foo
$ rsync -avH ./src/ host:dst/dir    # -> dst/dir/foo, with ./src attributes applied to dst/dir

tar can extract part of the tree, with or without the path components. It can also transform destination names with sed-like expressions, and much more. It is very powerful for that (after all, its main purpose was to be able to restore any file/directory from a tape archive, to the place we want), hence the tons of options.

I have a question for you : What is your “[*,.*]” supposed to do ? I don’t know which shell you use, but mine (bash) will not expand to what I think you actually mean (everything in current directory, including files whose name start with ‘.’, right ?).

1 Like