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

I need to:

  1. Copy all of a tree's folders (with all files, including hidden) under /sourcefolder/* preserving user privileges to /destfolder/

  2. If there is a conflict with a file (a file with the same name exists in destfolder), then

    • rename file in destfolder with a standard rule, like add "old" prefix to filename (readme.txt will become oldreadme.txt)
    • copy the conflicted file from source to destination

Conflicts between folders should be transparent - if same directory exists in both sourcefolder and destfolder, then preserve it and recursively copy its content according to the above rules.

I need also a .txt report that describes all files/folders added to destfolder and files that were renamed.

How can I accomplish this?

share|improve this question

rsync is probably what you want.

Try something like this as root:

rsync --backup --suffix=old --verbose --archive /sourcefolder/ /destfolder/

See "man rsync" for details of the options.

The output will (hopefully) be suitable for your text report. So run the command with this on the end:

> report.txt

share|improve this answer
    
Yep, pretty much this. – UtahJarhead Oct 16 '12 at 13:25

You must log in to answer this question.

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