-
Notifications
You must be signed in to change notification settings - Fork 0
/
ibackupinfo.rb
executable file
·64 lines (55 loc) · 1.62 KB
/
ibackupinfo.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env ruby
# ibackupinfo - does useful things to iTunes/idevicebackup backups.
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), "lib")
require 'BackupFile'
module IBackupInfo
class IBackupInfoApp
def initialize(args)
@args = args
@action = :help
parse_args
end
# Runs the app.
def run
case @action
when :help then print_usage
when :extract then extract(@args[1], @args[2])
end
end
# Prints out usage information.
def print_usage
puts "ibackupinfo - Gets useful information about iDevice backups from iTunes or idevicebackup."
puts "Usage:"
puts " ibackupinfo help : This help"
puts " ibackupinfo extract srcdir dstdir : Extracts a backup in srcdir to the dstdir"
puts "Future commands:"
puts " ibackupinfo applications srcdir : Print a list of applications installed in the backup"
puts " ibackupinfo info srcdir : Print out general information about the backup"
exit 0
end
# Extracts the backup
# TODO: Add -v switch and honor it, then pass it in to extract.
def extract(srcdir, destdir)
puts "Extracting backup in #{srcdir} to #{destdir}"
Dir.glob("#{srcdir}/*.mdinfo").each do |file|
backupfile = IBackupInfo::BackupFile.new(srcdir, File.basename(file.gsub(".mdinfo", "")))
backupfile.extract(destdir)
backupfile = nil
end
end
private
# Parse the args.
def parse_args
if @args.length > 0
case @args[0].to_sym
when :extract then
if @args.length == 3
@action = :extract
end
end
end
end
end
end
app = IBackupInfo::IBackupInfoApp.new(ARGV)
app.run