tmclean 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.md +135 -0
- data/bin/tmclean +126 -0
- metadata +100 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Michael Kessler
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
# Time Machine Clean
|
2
|
+
|
3
|
+
Clean old Time Machine backups with ease! You know, when you have backups from several machines on a single drive and
|
4
|
+
not a single one wants to backup anymore...
|
5
|
+
|
6
|
+
TMClean requires root privileges to delete the Time Machine backups.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Simply install from [RubyGems](https://rubygems.org/):
|
11
|
+
|
12
|
+
```Bash
|
13
|
+
$ sudo gem install tmclean
|
14
|
+
```
|
15
|
+
|
16
|
+
## Usage
|
17
|
+
|
18
|
+
```Bash
|
19
|
+
$ tmclean ruby-1.9.3-p194 1↵
|
20
|
+
Usage: tmclean last <number>
|
21
|
+
tmclean keep <number>
|
22
|
+
tmclean until <date description>
|
23
|
+
```
|
24
|
+
|
25
|
+
### Last
|
26
|
+
|
27
|
+
You can say how many backups you want to remove from Time Machine:
|
28
|
+
|
29
|
+
```Bash
|
30
|
+
$ sudo tmclean last 2
|
31
|
+
Getting the list of backups. Hold on a moment...
|
32
|
+
|
33
|
+
Keep 53 recent backups.
|
34
|
+
Delete the following backups:
|
35
|
+
|
36
|
+
/Volumes/Time Machine Backups/Backups.backupdb/otherland/2011-12-16-004025
|
37
|
+
/Volumes/Time Machine Backups/Backups.backupdb/otherland/2011-12-23-002310
|
38
|
+
|
39
|
+
Are you sure to delete these backups? (Y/N)
|
40
|
+
|
41
|
+
Deleting backups. You may want to grab some coffees, I'll take ages...
|
42
|
+
|
43
|
+
Delete /Volumes/Time Machine Backups/Backups.backupdb/otherland/2011-12-16-004025
|
44
|
+
Delete /Volumes/Time Machine Backups/Backups.backupdb/otherland/2011-12-23-002310
|
45
|
+
|
46
|
+
Done.
|
47
|
+
```
|
48
|
+
|
49
|
+
### Keep
|
50
|
+
|
51
|
+
You can say how many backups you want to keep, the rest is removed from Time Machine:
|
52
|
+
|
53
|
+
```Bash
|
54
|
+
$ sudo tmclean keep 50
|
55
|
+
Getting the list of backups. Hold on a moment...
|
56
|
+
|
57
|
+
Keep 50 recent backups.
|
58
|
+
Delete the following backups:
|
59
|
+
|
60
|
+
/Volumes/Time Machine Backups/Backups.backupdb/otherland/2011-12-30-000535
|
61
|
+
/Volumes/Time Machine Backups/Backups.backupdb/otherland/2012-01-07-174853
|
62
|
+
/Volumes/Time Machine Backups/Backups.backupdb/otherland/2012-01-15-001309
|
63
|
+
|
64
|
+
Are you sure to delete these backups? (Y/N)
|
65
|
+
|
66
|
+
Deleting backups. You may want to grab some coffees, I'll take ages...
|
67
|
+
|
68
|
+
Delete /Volumes/Time Machine Backups/Backups.backupdb/otherland/2011-12-30-000535
|
69
|
+
Delete /Volumes/Time Machine Backups/Backups.backupdb/otherland/2012-01-07-174853
|
70
|
+
Delete /Volumes/Time Machine Backups/Backups.backupdb/otherland/2012-01-15-001309
|
71
|
+
|
72
|
+
Done.
|
73
|
+
```
|
74
|
+
|
75
|
+
### Until
|
76
|
+
|
77
|
+
You can say which date the backups should be removed from Time Machine:
|
78
|
+
|
79
|
+
```Bash
|
80
|
+
$ sudo tmclean until 3 months ago
|
81
|
+
Getting the list of backups. Hold on a moment...
|
82
|
+
|
83
|
+
Keep 36 recent backups.
|
84
|
+
Delete the following backups:
|
85
|
+
|
86
|
+
/Volumes/Time Machine Backups/Backups.backupdb/otherland/2012-01-22-200324
|
87
|
+
/Volumes/Time Machine Backups/Backups.backupdb/otherland/2012-01-29-204948
|
88
|
+
/Volumes/Time Machine Backups/Backups.backupdb/otherland/2012-02-11-202151
|
89
|
+
/Volumes/Time Machine Backups/Backups.backupdb/otherland/2012-02-18-200728
|
90
|
+
/Volumes/Time Machine Backups/Backups.backupdb/otherland/2012-02-25-201024
|
91
|
+
/Volumes/Time Machine Backups/Backups.backupdb/otherland/2012-03-03-200513
|
92
|
+
/Volumes/Time Machine Backups/Backups.backupdb/otherland/2012-03-10-200939
|
93
|
+
/Volumes/Time Machine Backups/Backups.backupdb/otherland/2012-03-17-200645
|
94
|
+
/Volumes/Time Machine Backups/Backups.backupdb/otherland/2012-03-24-200450
|
95
|
+
/Volumes/Time Machine Backups/Backups.backupdb/otherland/2012-03-31-200929
|
96
|
+
/Volumes/Time Machine Backups/Backups.backupdb/otherland/2012-04-07-200722
|
97
|
+
/Volumes/Time Machine Backups/Backups.backupdb/otherland/2012-04-18-201209
|
98
|
+
/Volumes/Time Machine Backups/Backups.backupdb/otherland/2012-04-25-201422
|
99
|
+
/Volumes/Time Machine Backups/Backups.backupdb/otherland/2012-05-08-201136
|
100
|
+
|
101
|
+
Are you sure to delete these backups? (Y/N)
|
102
|
+
Cancelled.
|
103
|
+
```
|
104
|
+
|
105
|
+
## Author
|
106
|
+
|
107
|
+
Developed by Michael Kessler, sponsored by [mksoft.ch](https://mksoft.ch).
|
108
|
+
|
109
|
+
If you like TMClean, you can watch the repository at [GitHub](https://github.com/netzpirat/tmclean) and
|
110
|
+
follow [@netzpirat](https://twitter.com/#!/netzpirat) on Twitter for project updates.
|
111
|
+
|
112
|
+
## License
|
113
|
+
|
114
|
+
(The MIT License)
|
115
|
+
|
116
|
+
Copyright (c) 2012 Michael Kessler
|
117
|
+
|
118
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
119
|
+
a copy of this software and associated documentation files (the
|
120
|
+
'Software'), to deal in the Software without restriction, including
|
121
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
122
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
123
|
+
permit persons to whom the Software is furnished to do so, subject to
|
124
|
+
the following conditions:
|
125
|
+
|
126
|
+
The above copyright notice and this permission notice shall be
|
127
|
+
included in all copies or substantial portions of the Software.
|
128
|
+
|
129
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
130
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
131
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
132
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
133
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
134
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
135
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/bin/tmclean
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
def list
|
4
|
+
puts 'Getting the list of backups. Hold on a moment...'
|
5
|
+
`tmutil listbackups`.split("\n")
|
6
|
+
end
|
7
|
+
|
8
|
+
def ask(keep_backups, delete_backups)
|
9
|
+
puts ''
|
10
|
+
puts "Keep #{ keep_backups.length } recent backups."
|
11
|
+
puts 'Delete the following backups:'
|
12
|
+
puts ''
|
13
|
+
puts delete_backups
|
14
|
+
|
15
|
+
puts ''
|
16
|
+
puts 'Are you sure to delete these backups? (Y/N)'
|
17
|
+
|
18
|
+
if yes_or_no?
|
19
|
+
perform(delete_backups)
|
20
|
+
else
|
21
|
+
puts 'Cancelled.'
|
22
|
+
end
|
23
|
+
|
24
|
+
rescue
|
25
|
+
puts 'Stupid, that\'s not a valid answer.'
|
26
|
+
end
|
27
|
+
|
28
|
+
def yes_or_no?
|
29
|
+
system('stty raw -echo')
|
30
|
+
|
31
|
+
case STDIN.getc.upcase
|
32
|
+
when 'Y'
|
33
|
+
true
|
34
|
+
when 'N'
|
35
|
+
false
|
36
|
+
else
|
37
|
+
raise 'Invalid character.'
|
38
|
+
end
|
39
|
+
|
40
|
+
ensure
|
41
|
+
system('stty -raw echo')
|
42
|
+
end
|
43
|
+
|
44
|
+
def perform(backups)
|
45
|
+
puts ''
|
46
|
+
puts 'Deleting backups. You may want to grab some coffees, I\'ll take ages...'
|
47
|
+
puts ''
|
48
|
+
|
49
|
+
backups.each do |backup|
|
50
|
+
puts "Delete #{ backup }"
|
51
|
+
`sudo -u root tmutil delete "#{ backup }"`
|
52
|
+
end
|
53
|
+
|
54
|
+
puts ''
|
55
|
+
puts 'Done.'
|
56
|
+
end
|
57
|
+
|
58
|
+
#unless ENV['USER'] == 'root'
|
59
|
+
# puts 'Time Machine clean requires root privileges.'
|
60
|
+
# exit 2
|
61
|
+
#end
|
62
|
+
|
63
|
+
unless system('hash', 'tmutil')
|
64
|
+
puts 'The Time Machine command line utility `tmutil` was not found.'
|
65
|
+
exit 2
|
66
|
+
end
|
67
|
+
|
68
|
+
if ARGV.length == 0
|
69
|
+
puts 'Usage: tmclean last <number>'
|
70
|
+
puts ' tmclean keep <number>'
|
71
|
+
puts ' tmclean until <date description>'
|
72
|
+
exit 1
|
73
|
+
else
|
74
|
+
case ARGV[0]
|
75
|
+
when 'keep'
|
76
|
+
begin
|
77
|
+
keep = Integer(ARGV[1])
|
78
|
+
backups = list
|
79
|
+
delete = backups.slice!(0, backups.length - keep)
|
80
|
+
ask backups, delete
|
81
|
+
|
82
|
+
rescue TypeError, ArgumentError
|
83
|
+
puts 'Usage: tmclean keep <number>'
|
84
|
+
exit 1
|
85
|
+
end
|
86
|
+
|
87
|
+
when 'last'
|
88
|
+
begin
|
89
|
+
last = Integer(ARGV[1])
|
90
|
+
backups = list
|
91
|
+
delete = backups.slice!(0, last)
|
92
|
+
ask backups, delete
|
93
|
+
|
94
|
+
rescue TypeError, ArgumentError
|
95
|
+
puts 'Usage: tmclean last <number>'
|
96
|
+
exit 1
|
97
|
+
end
|
98
|
+
|
99
|
+
when 'until'
|
100
|
+
require 'chronic'
|
101
|
+
ARGV.shift
|
102
|
+
time = Chronic.parse(ARGV.join(' '), :context => :past)
|
103
|
+
|
104
|
+
if time
|
105
|
+
backups = list
|
106
|
+
|
107
|
+
delete_or_keep = backups.partition do |backup|
|
108
|
+
time < Date.parse(backup.match(/(\d{4}-\d{2}-\d{2})/)[1]).to_time
|
109
|
+
end
|
110
|
+
|
111
|
+
ask delete_or_keep[0], delete_or_keep[1]
|
112
|
+
|
113
|
+
else
|
114
|
+
puts 'Cannot parse date description.'
|
115
|
+
puts 'Usage: tmclean until <date description>'
|
116
|
+
exit 1
|
117
|
+
end
|
118
|
+
|
119
|
+
else
|
120
|
+
puts 'Usage: tmclean last <number>'
|
121
|
+
puts ' tmclean keep <number>'
|
122
|
+
puts ' tmclean until <date description>'
|
123
|
+
exit 1
|
124
|
+
|
125
|
+
end
|
126
|
+
end
|
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tmclean
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Michael Kessler
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-08-13 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: chronic
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: bundler
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rake
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
description: Clean old Time Machine backups with ease
|
63
|
+
email:
|
64
|
+
- michi@netzpiraten.ch
|
65
|
+
executables:
|
66
|
+
- tmclean
|
67
|
+
extensions: []
|
68
|
+
extra_rdoc_files: []
|
69
|
+
files:
|
70
|
+
- bin/tmclean
|
71
|
+
- LICENSE
|
72
|
+
- README.md
|
73
|
+
homepage: https://github.com/netzpirat/tmclean
|
74
|
+
licenses: []
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options: []
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
81
|
+
requirements:
|
82
|
+
- - ! '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
segments:
|
86
|
+
- 0
|
87
|
+
hash: 4304163877546570679
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 1.3.6
|
94
|
+
requirements: []
|
95
|
+
rubyforge_project:
|
96
|
+
rubygems_version: 1.8.24
|
97
|
+
signing_key:
|
98
|
+
specification_version: 3
|
99
|
+
summary: Clean old Time Machine backups with ease
|
100
|
+
test_files: []
|