Any way to copy data and skipping corrupt data instead of stopping?

OP
krs

krs


Joined
Sep 16, 2008
Messages
3,555
Reaction score
610
Points
113
Location
Canada
I can't imagine any application getting around that.
Can you comment on the approach in post #8?
I realize it's not an application as such, just a single line in the terminal app, but it seems to do what you suggest is quite difficult to do.
I don't know enough about terminal commands to even decide if that command line posted will work....or not.
 
Joined
Jan 1, 2009
Messages
15,494
Reaction score
3,853
Points
113
Location
Winchester, VA
Your Mac's Specs
MBP 16" 2023 (M3 Pro), iPhone 15 Pro, plus ATVs, AWatch, MacMinis (multiple)
@krs, from the symptoms and the reports, the drive is failing. Drives don't heal, they just continue to degrade. If you can get it replaced under warranty, I would do that. Your Terminal script might work for you to make it slightly easier to copy what you can and looks to be relatively low risk, so I would give it a go, see if it does what you need and if so, you have recovered what you can. Then get it replaced under warranty. I would wipe it clean, obviously, before sending it in for replacement.
 

Raz0rEdge

Well-known member
Staff member
Moderator
Joined
Jul 17, 2009
Messages
15,762
Reaction score
2,100
Points
113
Location
MA
Your Mac's Specs
2022 Mac Studio M1 Max, 2023 M2 MBA
Can you comment on the approach in post #8?
I realize it's not an application as such, just a single line in the terminal app, but it seems to do what you suggest is quite difficult to do.
I don't know enough about terminal commands to even decide if that command line posted will work....or not.

The command is a recursive force copy from source to destination. The force overwrites the destination files if they exist. The recursive will go down the folders and their sub-folders all the way down to the end.

It is however still prone to failing on a single file.

A crude script would be something like the following:
Code:
#!/bin/bash

# Save the source directory
SRC=$1

# Save the destination directory
DEST=$2

# Jump to the source directory
pushd $SRC

# Find a list of top level directories
find $SRC -type d -d 1 > /tmp/topleveldirs

for dir in `cat /tmp/topleveldirs`; do
    pushd $dir

    # Create the top level directory in the destination folder if it doesn't exist.
    if [ ! -e $DEST/$dir ]; then
        mkdir $DEST/$dir
    fi

    SDIRS=`find . -type d -d 1`
    if [ -z $SDIRS ]; then
         # This folder only has files
         for file in `ls`; do
             cp $file $DEST/$dir/$file
             if [ $? -ne 0 ]; then
                  echo "Unable to copy $dir/$file, moving on...."
             fi
         done
    else
        find $SRC -type d -d 1 > /tmp/subdirs
        for sdir in `cat /tmp/topleveldirs`; do
            pushd $sdir
            if [ ! -e $DEST/$dir/$sdir ]; then
                mkdir $DEST/$dir/$sdir
            fi
            SDIRS=`find . -type d -d 1`
            if [ -z $SDIRS ]; then
                # This folder only has files
                for file in `ls`; do
                    cp $file $DEST/$dir/$file
                    if [ $? -ne 0 ]; then
                        echo "Unable to copy $dir/$file, moving on...."
                    fi
                done
            else
                 # Time for a recursive function. :)
            fi
        done
    fi
done

Something like this. This is a poorly written script, but let me write something a little more robust and post back.

Can you give me a rough idea of folders and the files they hold so I can test it out?
 
OP
krs

krs


Joined
Sep 16, 2008
Messages
3,555
Reaction score
610
Points
113
Location
Canada
@krs, from the symptoms and the reports, the drive is failing. Drives don't heal, they just continue to degrade. If you can get it replaced under warranty, I would do that. Your Terminal script might work for you to make it slightly easier to copy what you can and looks to be relatively low risk, so I would give it a go, see if it does what you need and if so, you have recovered what you can. Then get it replaced under warranty. I would wipe it clean, obviously, before sending it in for replacement.
Thanks for the feedback - appreciate it.
Since I already copied what I needed, I have also wiped it clean.
Will call Staples (where I bought it) and Seagate to see what's involved in getting this replaced.

This is the first time I ever had an external fail on me - and that after only 5 months.
Previous external drive failures were always the bridge in the external, never the actual hard drive.
 
OP
krs

krs


Joined
Sep 16, 2008
Messages
3,555
Reaction score
610
Points
113
Location
Canada
Something like this. This is a poorly written script, but let me write something a little more robust and post back.

Can you give me a rough idea of folders and the files they hold so I can test it out?

Wow !!!

I didn't expect you to put that much effort into this.

The 8 TB drive had seven partitions, from 500 MB to 2 TB
There were four partitions used, two of the 500 MB ones for backups of two different Macs, a 1.5 TB one for videos I had collected over the years - these were all either mp4's or avi and the last used partition was a mix of files and folders I offloaded from my Mini - items I would only need to look at rarely.
There were folders nested three, maybe four down, and a mix of pdf's, word documents, excel, ppt. images (jpeg & tiff mostly), video and audio files (mp4 & mp3).
Pretty much run-of-the-mill, nothing really unique. All of that was around 170 MB
 

Raz0rEdge

Well-known member
Staff member
Moderator
Joined
Jul 17, 2009
Messages
15,762
Reaction score
2,100
Points
113
Location
MA
Your Mac's Specs
2022 Mac Studio M1 Max, 2023 M2 MBA
Wow !!!

I didn't expect you to put that much effort into this.

The 8 TB drive had seven partitions, from 500 MB to 2 TB
There were four partitions used, two of the 500 MB ones for backups of two different Macs, a 1.5 TB one for videos I had collected over the years - these were all either mp4's or avi and the last used partition was a mix of files and folders I offloaded from my Mini - items I would only need to look at rarely.
There were folders nested three, maybe four down, and a mix of pdf's, word documents, excel, ppt. images (jpeg & tiff mostly), video and audio files (mp4 & mp3).
Pretty much run-of-the-mill, nothing really unique. All of that was around 170 MB

OK, that's what I imagined, but just wanted to make sure you didn't have something more funky. I imagine you want things copied from one location to a second, different partitions on the same drive or different drives.

The arguments to the script will likely be the top of the source folder to dig through and the top of the destination folder where you want everything copied. I'll post back when I get that working.
 
Joined
May 21, 2012
Messages
10,735
Reaction score
1,188
Points
113
Location
Rhode Island
Your Mac's Specs
M1 Mac Studio, 11" iPad Pro 3rd Gen, iPhone 13 Pro Max, Watch Series 7, AirPods Pro
If you do get another 8TB drive, use folders instead of partitions, it will save you a lot of trouble.
 
OP
krs

krs


Joined
Sep 16, 2008
Messages
3,555
Reaction score
610
Points
113
Location
Canada
If you do get another 8TB drive, use folders instead of partitions, it will save you a lot of trouble.

Why would you say that?
I don't think it would have made any difference in this case - the drive just started to fail.

In any case, using folders wouldn't work since I'm using three of the 500 MB partitions as secondary backup for three of the Macs.
I don't think one can use SD or CCC to make a bootable clone to a folder.
These backups not showing up when I started the Mac with the option key held down were what even suggested there was a problem to start with.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top