add(function): delete old time machine backups

This commit is contained in:
Léana 江 2023-01-02 21:31:25 +01:00
parent 577bf847aa
commit b6ac14fc7e
2 changed files with 13 additions and 0 deletions

View file

@ -0,0 +1,12 @@
function delete_old_tm_backups
set -f latest (sudo tmutil latestbackup | sed "s/.*\/\(.*\)\.backup/\1/g")
set -f mount_point (sudo tmutil destinationinfo | grep 'Mount Point' | sed "s/.*: \(.*\)/\1/g")
set -f backups (sudo tmutil listbackups -t)
echo $latest
echo $mount_point
for backup in $backups
if test "$backup" != "$latest"
sudo tmutil delete -d $mount_point -t $backup
end
end
end