3

I have discovered the hard way that Apple's "Migration Assistant" doesn't always preserve file timestamps (i.e., created/modified dates in ~/Documents), and I now have a new machine with some folders containing files that are timestamped to the migration — not the original timestamps. It's a mess, and sort of a disaster for my workflow. I've just learned that many others have been burned by this before me.

Question: is there some way that I can use rsync, perhaps with the --size-only flag to restore the original, correct timestamps?

I need to create an NFS share, I guess, to rsync between two different macs. Or maybe I could do it via ssh?

If this is possible, any pointers on how to actually do it?

3
  • Do you still have the original files/timestamps?
    – Seamus
    Commented Jul 27, 2022 at 7:10
  • Many of the original files/timestamps are on another machine, yes.
    – mrob
    Commented Jul 28, 2022 at 9:53
  • OK - as long as you have the "originals", you can repair the timestamps, as well as the other metadata - even the "extended attributes".
    – Seamus
    Commented Jul 28, 2022 at 17:08

1 Answer 1

2

"I have discovered the hard way that Apple's "Migration Assistant" doesn't always preserve file timestamps"

Comment: It seems that has become Apple's MO - you must discover all things the "hard way".

Caveats: I don't actually know what Migration Assistant does as I've never used it. However, based on the rsync example below, I've shown it will preserve your timestamps (and other metadata you may have lost).

I used rsync ver 3.2.4 for this answer, installed from MacPorts. I can't guess what features your version of rsync includes. You should consider upgrading rsync with MacPorts or Homebrew. Apple hasn't upgraded "their" version of rsync in many years, and it lacks the ability to support the methods and options used here.

Background: I began using rsync as my primary backup tool for macOS some time ago because I had to address the same issues as you: mangled and missing metadata. In my case, the issue was perhaps exacerbated by crossing a file system boundary - from APFS on my local drive to btrfs via SMB on a 'Synology NAS'. In your case, using Migration Assistant, I cannot imagine how Apple could not get the timestamp metadata correct - but you're not the only one who's reported this issue.

I made some notes while working to resolve my issue, and they morphed into a "recipe" in this GitHub repo. I'll keep this answer brief as most of the details are covered in that document.


Q: Can I use rsync to fix the timestamps that Migration Assistant trashed?

A: Yes - as shown below and verified

rsync with metadata preservation

rsync effectively copies data from a source (the "from" location) to a destination (the "to" location). If you are using a fileserver (NAS) as a backup for your Mac, the GitHub recipe will provide complete guidance to make and restore an rsync backup without losing metadata (attrs & xattrs).

However, as you need only to "migrate" files & folders from an old Mac to a new Mac, there is no need to involve an intermediate NAS. Consequently, the GitHub recipe can be simplified.

The scenario below assumes that the remote folders have been mounted (perhaps via 'File Sharing' in 'System Settings'). Alternatively, if you prefer to enable 'Remote Login' you can run rsync via SSH.

The following command code block shows the command syntax & options needed for rsync to perform an old Mac-to-new Mac "migration":

SCENARIO: from "oldMac" to "newMac"

Assuming the source & destination folders are:
SOURCE: /Users/MyHome/oldMacFolder/
DESTINATION: /Users/MyHome/newMacFolder

From Terminal.app on your "old Mac":

% SRC-FLDR="/Users/MyHome/oldMacFolder/"
% DST-FLDR="/Users/MyHome/newMacFolder"
% rsync -rlAXtgoDivv --dry-run -M--fake-super $SRC-FLDR $DST-FLDR

Notes:

  1. --dry-run this option prevents rsync from actually copying any files! It's used so that you can see what will be copied once the option is removed.

  2. If you've not set up file-sharing to mount the remote folder(s), you may use an SSH connection by adding the option -e ssh to the rsync command. This will require that you've set up 'Remote Login' in 'System Settings'.

Verifying Results - Preservation of All Metadata:

The GitHub recipe includes a short zsh script that will stat all of the files, folders, links, etc between the SOURCE and DESTINATION folders. It may be run after the rsync operations to verify that the chosen stat attributes have been preserved.

The rsync options presented here will do more than preserve the metadata containing the date-time stamps; they will also preserve all extended attributes (xattrs) . The GitHub recipe also includes a simple script to compare the output of xattr -lrsvx for all files (that have xattrs) in the SOURCE and DESTINATION directories.

The stat utility that I use here is the GNU coreutils version 9.1. The find version I use is the GNU findutils version 4.9.0. Both are readily available through MacPorts (and likely through Homebrew) for virtually every version of macOS. The xattr command is a macOS utility.


References and Further Reading:

  1. There’s more to files than data: Extended Attributes

  2. APFS: Extended attributes revisited

  3. From quarantine to provenance: extended attributes

  4. From quarantine to provenance: how xattrs are copied

  5. Extended attributes

  6. How to use rsync over ssh

2
  • Is your shell script on GitHub using gnu stat? If so could you show us how to convert the syntax into BSD stat?
    – fd0
    Commented Jul 27, 2022 at 11:11
  • @fd0: Yes - I used stat from GNU coreutils 9.1. You can find the GNU docs for stat online. FreeBSD docs for stat are here - but I have no idea how that matches against your version - on whatever macOS you're using. FWIW, my general preference is for utilities and documentation that is more recent, as I feel there's something positive to be said for software maintenance.
    – Seamus
    Commented Jul 27, 2022 at 23:38

You must log in to answer this question.

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