Skip to content

Instantly share code, notes, and snippets.

@maltejk
Created January 10, 2019 19:09
Show Gist options
  • Save maltejk/6c11ac3b45d35ac1ea4ed146cdf9c418 to your computer and use it in GitHub Desktop.
Save maltejk/6c11ac3b45d35ac1ea4ed146cdf9c418 to your computer and use it in GitHub Desktop.
#!/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}"
@maltejk
Copy link
Author

maltejk commented Jan 10, 2019

TODO: handle multiple drives.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment