5

I recently completely reinstalled macOS on my MacBook but I forgot to save my personalised .bash_profile. I was stupid enough not to dump it on Gist for future use, and now I'm looking into restoring it. I have several Time Machine backups on an external SSD-drive, would it be possible to restore this file somehow, and if so, where can I find this file so I can copy it over to my current macOS installation?

Searching through the entire backup folder didn't show me any useful results. I have gone through several threads to try to locate where this file might be saved, but as of now I couldn't come across a good answer which covers my problem. Thanks!

2
  • Find your home folder in Finder , then enter time machine – mmmmmm Sep 7 '19 at 12:53
  • Geez, so simple. Thanks a lot Mark! :) – Hidde IJzerman Sep 7 '19 at 15:04
8

You do not even need to enter Time Machine, although your Time Machine drive must be connected and mounted.

In Terminal, which by default opens to your $HOME directory, you can use the following command, literally, to copy the .bash_profile file to your $HOME directory:

cp -av /Volumes/*/Backups.backupdb/*/Latest/*/Users/$USER/.bash_profile .

Note that this command assumes there is only one volume attached that has a Backups.backupdb directory in its root directory.

1
  • This saved my life. Thankyou! – mattos Oct 21 '19 at 3:50
2

In Finder: Set to make visible unvisible files, select your home folder, Enter TimeMachine, select a date before the reinstall, select .bash_profile and restore it.

You must log in to answer this question.

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