{"id":22119545,"url":"https://github.com/bglezseoane/tmlatestbackup","last_synced_at":"2025-07-25T12:32:48.382Z","repository":{"id":57669965,"uuid":"324780338","full_name":"bglezseoane/tmlatestbackup","owner":"bglezseoane","description":"Really simple CLI app to obtain the date of the last Mac OS Time Machine backup","archived":false,"fork":false,"pushed_at":"2021-03-04T16:55:17.000Z","size":30,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-31T11:47:32.716Z","etag":null,"topics":["backups","macos","time-machine"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bglezseoane.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-12-27T14:34:48.000Z","updated_at":"2022-07-04T18:40:18.000Z","dependencies_parsed_at":"2022-09-26T20:40:41.636Z","dependency_job_id":null,"html_url":"https://github.com/bglezseoane/tmlatestbackup","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bglezseoane%2Ftmlatestbackup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bglezseoane%2Ftmlatestbackup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bglezseoane%2Ftmlatestbackup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bglezseoane%2Ftmlatestbackup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bglezseoane","download_url":"https://codeload.github.com/bglezseoane/tmlatestbackup/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227559255,"owners_count":17786787,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backups","macos","time-machine"],"created_at":"2024-12-01T14:15:08.136Z","updated_at":"2024-12-01T14:15:09.385Z","avatar_url":"https://github.com/bglezseoane.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"`tmlatestbackup`\n=================\n\n*Really simple CLI app to obtain the date of the last Mac OS Time Machine backup.*\n\n![Status](http://www.borja.glezseoane.es/img/project-status-label-development.svg \"Status: development\")\n\n\n## Install\n\nThe recommended installation option is use Homebrew with the command:\n\n```sh\nbrew install bglezseoane/tap/tmlatestbackup\n```\n\nYou can only install the program with Cargo, with the command:\n\n```sh\ncargo install tmlatestbackup\n```\n\n\n\n## Use\n\nThe normal use of the tool is very simple. You only need to run:\n\n```sh\ntmlatestbackup\n```\n\nAnd obtain the date of the last Time Machine backup with format like: `2018-11-21-102312`.\n\n\n### Achieve permissions against Mac OS System Integrity Protection\n\nIf your current **terminal app** has **full disk access** and you use `tmlatestbackup` **since it**, the tool will works fine. If you only want to work with `tmlatestbackup` **since your terminal** or since scripts used by you since your terminal, **the above is sufficient** and the following steps are irrelevant to your use case.\n\nOtherwise, if you want to use the tool since an script routine as **`launchd` agent**, the tool is going to fail due to System Integrity Protection.\n\nMac OS System Integrity Protection block `tmlatestbackup` because the tool try to access protected Time Machine features and it doesn't inherit permissions —**using it since the terminal, inherit terminal granted ones**—. To achieve permissions, you need to grant them adding the binary (`/usr/local/bin/tmlatestbackup`) to the list of applications with full disk access —System Preferences \u003e Security \u0026 Privacy \u003e Full Disk Access \u003e Add—.\n\nThe path `/usr/local/bin/tmlatestbackup` could be different if you have installed with Cargo. Any case, you can check it with `which tmlatestbackup`.\n\nIf your agent only needs to run the tool and no more stuff, you can add the following lines to the agent `Info.plist` and it will work (after previously indicated step):\n\n```xml\n\u003ckey\u003eProgramArguments\u003c/key\u003e\n    \u003carray\u003e\n      \t\u003cstring\u003e/usr/local/bin/tmlatestbackup\u003c/string\u003e\n    \u003c/array\u003e\n```\n\nFor any reason, to work with the tool since the `launchd` agent and **integrated in a shell script**, you need to always run it as `open -a '/usr/local/bin/tmlatestbackup'` and not directly as a command (e.g. `/usr/local/bin/tmlatestbackup`). I.e., if you use, e.g., the following agent specification...\n\n```xml\n\u003ckey\u003eProgramArguments\u003c/key\u003e\n    \u003carray\u003e\n      \t\u003cstring\u003e/Users/You/scripts/script_which_calls_tmlatestbackup.sh\u003c/string\u003e\n    \u003c/array\u003e\n```\n\n... you need to run `tmlatestbackup` as follows:\n\n```sh\n# 'script_which_calls_tmlatestbackup.sh'\n# ...\n\nopen -a '/usr/local/bin/tmlatestbackup'\n# And not '/usr/local/bin/tmlatestbackup\n\n# ...\n```\n\nWhen run with `open -a`, the command don't return an error code if the launched application fails, so in order to integrate this step in a well designed script, the next approach is recommended:\n\n```sh\n# ...\n\n# Create temporary file to save the output of the 'open' command\nTMP_OPEN_TMLATESTBACKUP_STDOUT=$(mktemp -t open_tmlatestbackup)\n\n# Run and wait\nopen -W -a '/usr/local/bin/tmlatestbackup' \\\n\t--stdout \"$TMP_OPEN_TMLATESTBACKUP_STDOUT\" \\\n\t--stderr \"$TMP_OPEN_TMLATESTBACKUP_STDOUT\"\n\n# Check and act attending to the process success\nif ! [[ \"$(cat \"$TMP_OPEN_TMLATESTBACKUP_STDOUT\")\" \\\n\t=~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}-[0-9]{6}$ ]]\nthen\n\t\u003e\u00262 echo \"Error using 'tmlatestbackup'.\"\n\trm \"$TMP_OPEN_TMLATESTBACKUP_STDOUT\"\n\texit 1 \nfi\n\n# Clean\nrm \"$TMP_OPEN_TMLATESTBACKUP_STDOUT\"\n\n# ...\n```\n\n\n\n## Motivation\n\nOn my Mac OS machine I have some scripts that cannot work as agents because it is prevented by System Integrity Protection, which only allows granting permissions to binary programs. That, coupled with the fact that I wanted to learn the Rust language, motivated me to write this simple program in order to have the conflicting step in a compiled program to authorize it and can maintain my script routine working elegantly —and not with pseudo-compiled shell scripts inserted in a compiled language program—. However, at the end of the day `tmlatestbackup` is a potentially useful generic purpose program.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbglezseoane%2Ftmlatestbackup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbglezseoane%2Ftmlatestbackup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbglezseoane%2Ftmlatestbackup/lists"}