Created
February 21, 2023 03:41
-
-
Save darren/2f8e7c5a18ac8cee03f7da9a9757b7d5 to your computer and use it in GitHub Desktop.
Revisions
-
darren revised this gist
Feb 21, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -32,4 +32,4 @@ function tml() { 然后执行 . ~/.profile ``` 之后就可以用命令`tml`列出所有的快照列表,用`tmc`清空所有的备份快照 -
darren created this gist
Feb 21, 2023 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ ## 清理时间机器备份遗留的快照命令行工具 把这两个函数定义放入~/.profile ```bash function tmc() { for d in $(mount |grep Time|awk '{print $3}'); do diskutil umount "$d HD"; done before=$(df -hl /System/Volumes/Data |awk '{print $3}' |tail -n1) count=0 for snapshot in $(tmutil listlocalsnapshots /|awk -F. '{print $4}');do let 'count++' echo "delete snapshot $snapshot" tmutil deletelocalsnapshots $snapshot; done after=$(df -hl /System/Volumes/Data |awk '{print $3}' |tail -n1) if [[ $count -ne 0 ]]; then echo "Total $count snapshot(s) deleted, Size change: $before ===> $after" else echo "No snapshot deleted" fi } function tml() { tmutil listlocalsnapshots /|awk -F. '{print $4}' } ``` ```bash 然后执行 . ~/.profile ``` 之后就可以用命令tml列出所有的快照列表,用tmc清空所有的备份快照