Created
January 10, 2019 19:09
-
-
Save maltejk/6c11ac3b45d35ac1ea4ed146cdf9c418 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
_file_abspath="$(echo "$1" | ruby -e 'puts File.absolute_path(STDIN.read)')" | |
_file_volumename="$(diskutil info -plist / | plutil -convert json -o - - | ruby -rjson -e 'puts JSON.parse(STDIN.read)["VolumeName"]')" | |
_file_backup="${_file_abspath}.tmutil-backup" | |
_tmutil_latestbackup="$(tmutil latestbackup)" | |
mv "${_file_abspath}" "${_file_backup}" | |
tmutil restore -v "${_tmutil_latestbackup}/${_file_volumename}${_file_abspath}" "${_file_abspath}" || mv "${_file_backup}" "${_file_abspath}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TODO: handle multiple drives.