Created
May 5, 2022 09:38
-
-
Save gingerbeardman/ea0a213eb5e361ba9e7e8d004300c91b to your computer and use it in GitHub Desktop.
Restore the most recent copy of a file from Time Machine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# by Matt Sephton, @gingerbeardman | |
currentFile="$@" | |
backupRoot=`cd "/Volumes/Backups of matt/";cd *.previous;pwd` | |
localData="/System/Volumes/Data" | |
backupData="$backupRoot/Mac mini - Data" | |
localExternal="/Volumes/External" | |
backupExternal="$backupRoot/External" | |
localApp="/Applications" | |
backupApp="$backupRoot/Mac mini - Data/Applications" | |
backupFile=$currentFile | |
backupFile="${backupFile/$localData/$backupData}" | |
backupFile="${backupFile/$localExternal/$backupExternal}" | |
backupFile="${backupFile/$localApp/$backupApp}" | |
/usr/local/bin/trash "$currentFile" | |
tmutil restore "$backupFile" "$currentFile" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# by Matt Sephton, @gingerbeardman | |
currentFile="$@" | |
backupRoot="/Volumes/Tardis/Backups.backupdb/matt/Latest" | |
localData="/System/Volumes/Data" | |
backupData="/Mac mini - Data" | |
localExternal="/Volumes/External" | |
backupExternal="$backupRoot/External" | |
localApp="/Applications" | |
backupApp="$backupRoot/Mac mini - Data/Applications" | |
backupFile=$currentFile | |
backupFile="${backupFile/$localData/$backupData}" | |
backupFile="${backupFile/$localExternal/$backupExternal}" | |
backupFile="${backupFile/$localApp/$backupApp}" | |
/usr/local/bin/trash "$currentFile" | |
tmutil restore "$backupFile" "$currentFile" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment