finding same files across hardrives

Chris F.A. Johnson cfaj-uVmiyxGBW52XDw4h08c5KA at
Tue Dec 2 15:58:24 UTC 2008

On Tue, 2 Dec 2008, Jose wrote:

> Chris F.A. Johnson wrote:
>> On Sat, 29 Nov 2008, Jose wrote:
>>> Thanks for the script, basically not having tape backups I got to copy the 
>>> same files on different hard drives as "backups", but now I have a backup 
>>> solution and I would like to consolidate a single copy of the data and 
>>> properly back it up
>>     Am I missing something? Why do you need to do anything with the
>>     old backups? Back up your data as it is now and remove all the old
>>     stuff.
> For the sake of having my a backup in proper order, meaning I know whare is 
> what when I need it, yes, I still would prefer to consolidate everything 
> before I back it up

    I've been trying to figure out exactly what you want. Does this
    describe it:

      Your have data in multiple areas, say /path/to/area1,
      /path/to/area2 and /path/to/area3. Some files may be duplicated
      in more than one area. You want to move everything to one area,
      discarding duplicate files. Is that right?

      If so, create the destination directory (e.g., area51) and:

cp -a /path/to/area1/ /path/to/area2/ /path/to/area3/ area51

      Now, all the files are in area51 (with the original directory
      structures retained) and you can delete the originals. Duplicate
      files will have been deleted (assuming the directory structure is
      the same in each area).

      If you want to keep duplicate files for further examination:

cp -a --backup=numbered /path/to/area1/ /path/to/area2/ /path/to/area3/ area51

      All duplicates (again, assuming the same directory structures)
      will have a numbered extension.

      If you want to catch all files with duplicate names, you can copy
      them to a single flat directory:

find /path/to/area1/ /path/to/area2/ /path/to/area3/ -type f -exec cp {} area51 \;

      To keep numbered duplicates:

find /path/to/area1/ /path/to/area2/ /path/to/area3/ -type f -exec cp --backup=numbered {} area51 \;

    Chris F.A. Johnson, webmaster         <>
    ========= Do not reply to the From: address; use Reply-To: ========
    Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
The Toronto Linux Users Group.      Meetings:
TLUG requests: Linux topics, No HTML, wrap text below 80 columns

More information about the Legacy mailing list