Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I am trying to come up with the safest way to move data between two drives, designed to handle the worst possible circumstances. For example: if you were trying to move the only existing copies of pictures of your child being born while a crazed monkey was roaming the halls and might pull the power cord on your Mac and/or the external drives at any moment.

Note that there is a similar question for syncing, but I'm asking specifically about moving which is a different problem, because (amongst other reasons) you have to be able to tell which files have been moved and which have not. You also need to account for the possibility that some files might have been copied to the intended destination but not removed from the source.

This solution does not have to use the GUI. In fact I find the Terminal comforting. I don't mind installing new programs (especially if available via brew). Only requirement is that the solution be compatible with Mac OS X 10.8.

Here is the work-flow solution that I have in mind:

  1. cp (copy) files (if needed)
  2. checksum files (either after copy or if an existing copy of the file is found)
  3. Move original file to trash (not rm!) after a file has been moved to new location

More specifically:

  1. User specifies where files should be moved to (target/destination folder). Call it $DEST (This would be similar to the --target-directory flag to GNU mv

  2. User specifies files/folders which should be moved to $DEST. Call that $INPUT

  3. Script would then look for each file/folder from $INPUT on $DEST.

  4. If file/folder is found on $DEST then checksum it against $INPUT copy.

  5. If checksum matches, move $INPUT copy to trash.

  6. If checksum does not match, replace $DEST copy with $INPUT

Note: while I do care about permissions (technically I care about "executability"), I do not care about "ownership" as I am the only user of this local system.

Before I go and re-invent the wheel, does something like this already exist?

Basically I want as much assurance as possible that a good copy has been made before I delete the original, without doing a full sync between the two drives.

share|improve this question
add comment

1 Answer

I'd use the same solution as for syncing, with the option given to rsync to remove the source files. Something like this:

rsync -azv --remove-source-files $INPUT $DEST

As you mentioned, why reinvent the wheel? rsync checksums each transferred file to be sure it has transferred correctly.

share|improve this answer
    
Someone on one of the StackExchange sites said that rsync does NOT checksum when doing a local copy. I can't find the citation at the moment, but I saw it just within the past week or so. They were talking about Linux, and had used some tool to check I/O and did not see any evidence that it was checking local copies. Is there a way to confirm that it does or does not? –  TJ Luoma May 30 '13 at 12:35
    
Here's the place where one person said they looked at the code and it DOES check, and someone else said that he checked and it does NOT. unix.stackexchange.com/questions/30970/… –  TJ Luoma May 30 '13 at 17:32
add comment

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.