Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.