• Stars
    star
    138
  • Rank 264,508 (Top 6 %)
  • Language
    Shell
  • License
    GNU General Publi...
  • Created over 9 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Zsh script to clean up Time Machine backups and reduce its size

Time Machine Cleanup

tm-cleanup.sh is a Zsh script to clean up Time Machine backups and reduce its size. tm-cleanup.sh provides two interfaces:

  • A command-line interface.

  • An interactive, dialog-based interface.

tm-cleanup.sh requires super-user privileges, so it's normally executed using sudo.

tm-cleanup.sh

tm-cleanup.sh is a Zsh script that lists the completed Time Machine snapshots and deletes those that satisfy the specified criteria. Two types of deletion criteria exist:

  • By date: snapshots that are older than a specified number of days are deleted. The default threshold is 30 days.

  • By number: a maximum number of snapshots is retained and oldest snapshots are deleted.

Only one deletion criteria can be specified.

The syntax of tm-cleanup.sh is the following:

$ tm-cleanup.sh (-d days | -n number) [-f] [-x]
$ tm-cleanup.sh [-h]

where

  • If -d is specified, backups older than the specified number of days will be deleted. days is a positive integer number.

  • -n specifies the number of backups to retain. number is a positive integer number.

  • By default, tm-cleanup.sh exits and prints an error message if a Time Machine backup is currently in progress. -f forces the backup deletion concurrently.

  • -h prints the help message and exits the program.

  • -x performs a dry clean: it will print the list of operations that will be performed without actually performing any.

This script never deletes the latest snapshot, no matter the value of the -d or -n options.

Interactive Interface

tm-cleanup.sh also provides an interactive interface which is useful if the user wishes to pick which backups to delete using a dialog-based interface. The interactive interface can be launched by passing no arguments to the script:

$ tm-cleanup.sh

The interactive interface starts with a menu showing the available operations a user can perform:

tm-cleanup.sh - Start

The Delete backups operation brings the user to a dialog where the backups to delete can be selected. By default, backups are shown in reverse chronological order (i.e.: latest first) and all except the first are selected.

tm-cleanup.sh - Choose backups

The backups deletion may take a long time to complete, during which a progress dialog is shown.

tm-cleanup.sh - Backup deletion progress

At the end of the deletion, a confirmation is shown to the user.

tm-cleanup.sh - Backup deletion done

The script prevents users to delete all the backups. If all the backups are selected, an error message is shown.

tm-cleanup.sh - Invalid backup choice

Installation

This package is configured using the GNU Autotools. For this reason, users who just wish to use this software have to download a release tarball. Release tarball are attached to each release. The latest release of this package can always be found using the latest tag.

Once a release tarball has been downloaded and uncompressed, this package can be installed using the following commands:

$ ./configure
$ sudo make install

Please, refer to the Autotools documentation if you'd like to customise the installation procedure.

The package can then be uninstalled using the following command:

$ sudo make uninstall

To make path changes visibile in an existing Zsh session, execute the rehash command:

$ rehash

Requirements

Since a compatible version of Zsh is bundled with OS X, the command-line interface of this script has no other requirements. To use the dialog-based interface, dialog is required.

Bug Reports

Bug reports can be sent directly to the authors.


Copyright (C) 2015-2017 Enrico M. Crisostomo

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

More Repositories

1

fswatch

A cross-platform file change monitor with multiple backends: Apple OS X File System Events, *BSD kqueue, Solaris/Illumos File Events Notification, Linux inotify, Microsoft Windows and a stat()-based backend.
C++
5,042
star
2

flags

Public domains world flag images.
100
star
3

EMCCountryPickerController

EMCCountryPickerController is a view controller allowing users to choose and filter countries in a list.
Objective-C
64
star
4

jwt-cli

A shell library to decode JWT tokens
Shell
42
star
5

fsw

A file change monitor with multiple backends: Apple OS X File System Events API, *BSD kqueue, Linux inotify and a stat-based backend.
C++
42
star
6

semver-utils

A C/C++ library and an utility to compare and manipulate versions numbers complying with Semantic Versioning 2.0.0
M4
14
star
7

link-osx-framework-headers

Link the specified OS X framework header directory and all its sub-frameworks' header directories in the current directory.
Shell
6
star
8

libxdgbasedir

Simple C++ implementation of the XDG Base Directory Specification
M4
5
star
9

EMCLoginItem

An Objective-C library to query, add and remove login items in Apple OS X.
Objective-C
5
star
10

display-control

A macOS utility to enumerate displays and store and set their brightness level
M4
4
star
11

macports-utils

MacPorts utilities
Shell
3
star
12

pdfform

A command-line tool to manipulate PDF forms
Java
1
star
13

mvn-version

M4
1
star
14

hostage

A command line utility to programmatically edit the host name database file (/etc/hosts)
C++
1
star
15

poudriere-utils

Poudriere utilities
M4
1
star
16

dsc

A disk space checking script that notifies the user on standard output and by email.
Shell
1
star
17

netbeans-gnu-m4-macro-processor-language-support

NetBeans - GNU M4 Language Support
Java
1
star
18

bitbucket-utils

BitBucket Utils
Shell
1
star
19

netbeans-gnu-autotools-language-support

NetBeans - GNU Autotools Language Support
Java
1
star