Skip to content

Instantly share code, notes, and snippets.

@gingerbeardman
Created May 5, 2022 09:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gingerbeardman/ea0a213eb5e361ba9e7e8d004300c91b to your computer and use it in GitHub Desktop.
Save gingerbeardman/ea0a213eb5e361ba9e7e8d004300c91b to your computer and use it in GitHub Desktop.
Restore the most recent copy of a file from Time Machine
#!/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"
#!/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