在命令行上使用iOS设备和备份

更新

iPhone Backup Extractor包含一个名为rictl的命令行工具,用于处理iOS备份和设备。 rictl在运行iPhone Backup Extractor的任何平台上运行,并且在参数和帮助语法以及shell返回方面与任何UNIX样式的命令行工具一样工作。

功能一览:

  • UNIX兼容格式( $? shell返回代码,区域设置格式化日期,awk友好输出, stdout导出数据流)
  • 支持多个同步搜索路径
  • 支持所有格式的加密备份
  • 支持相对和基于家庭的( ~ )路径

rictl shown in macOS Terminal
rictl显示在macOS终端中

rictl shown in Windows Command Prompt
Windows命令提示符中显示的rictl

快速入门:从iOS备份中提取数据库文件

查找本地系统上可用的备份:

$ rictl backup search
00000000-0000000000000000 02/07/2019 11:33:41 12.3.1 iPhone11,6 ok

从备份中提取所有数据库文件(请注意正则表达式格式):

$ rictl backup extract -u 00000000-0000000000000000 -r "\.db"
Extracting HomeDomain/Library/Voicemail/voicemail.db
Extracting HomeDomain/Library/Safari/Bookmarks.db
Extracting RootDomain/Library/Caches/locationd/consolidated.db
Extracting WirelessDomain/Library/CallHistory/call_history.db
...

命令词汇表

获得帮助

您可以使用rictl help命令,按照您的预期使用rictl获得帮助:

$ rictl help
Usage: rictl <command> [args]

Available commands:
   backup   Work with a local backup
   device   Work with devices over USB and Wi-Fi

Use 'rictl help <command>' for detailed help on a particular command

rictl exposes a backup mode for working with local backups, and a device mode for working with iOS devices over USB or Wi-Fi.

使用本地备份

$ rictl help backup
Usage: rictl backup <command> [args]
Work with local backups

Available commands:
  search   Search for local backups
  info     Show info about a backup
  list     List files in a backup
  extract  Extract files from a backup
  export   Export data from a backup

Use 'rictl help backup <command>' for detailed help on a particular backup command

使用备份时,有五个选项: searchinfolistextractexport

使用search来搜索本地iOS备份

$ rictl help backup search
Usage: rictl backup search [args]
Search for local backups

Available arguments:
  -s, --search-path=VALUE    path to search for backups (two directories deep)
  -l                         include full path in listing output
  -h, --help                 show this message and exit

最简单的是, search将显示系统上的备份:

$ rictl backup search
00000000-0000000000000000 02/07/2019 11:33:41 12.3.1 iPhone11,6 ok

显示的字段是以空格分隔的,并且是:

选项-l显示备份路径

您可以使用-l在备份路径中包含其他输出字段:

$ rictl backup search -l
00000000-0000000000000000 02/07/2019 11:33:41 12.3.1 iPhone11,6 ok /Users/afit/Library/Application Support/MobileSync/Backup/00000000-0000000000000000
选项-s搜索其他路径

在查找备份时,您可以使用-s包含其他搜索路径。

$ rictl backup search -s /Users/afit/Google\ Drive\ File\ Stream/My\ Drive/My\ backups/  -s Downloads/
00000000-0000000000000000                02/07/2019 11:33:41 12.3.1 iPhone11,6 ok
DB72CB76A00CB81675F19907D4AC2B298628D83C 09/06/2014 13:57:08 7.1.1  iPhone6,2 ok
DB72CB76A00CB81675F19907D4AC2B298628D83C 23/07/2014 12:37:55 8.0    iPhone6,2 ok
DB72CB76A00CB81675F19907D4AC2B298628D83C 28/07/2014 12:43:56 8.0    iPhone6,2 ok
CDBF062964613D325EB9E41AD83E85EA16B7E399 10/02/2014 14:29:59 7.0.4  iPad4,1   ok
57BE3B9E8087809F53666B887B9DD81B06299078 29/07/2014 14:18:54 7.1    iPhone3,1 ok
F60040E968F533434B9B6CCA10C7E0C673B7CC13 07/10/2014 09:44:17 8.0.2  iPhone7,2 ok
CC5D2A27218BD9E4A14B1E59918171A8676EF5BB 26/03/2015 11:07:42 2.2.1  iPhone1,1 ok
46A663D1A1A5C5146476A2C6164EA5F5FE771294 26/03/2015 11:09:54 4.2.1  iPhone1,2 ok
9F8FDEEFFCDA4BD53CA4D6F8229A04497CA5FA4C 31/10/2016 17:05:36 10.1.1 iPhone9,4 ok
  • 正如您所期望的那样,您可以在路径中引用( "My folder" )或转义( My\ folder )空格
  • -s可用于指定备份文件夹 包含备份的文件夹

使用info从本地iOS备份中获取信息和元数据

$ rictl help backup info
Usage: rictl backup info [args]
Show info about a backup

Available arguments:
  -u, --udid=VALUE           backup UDID
  -s, --search-path=VALUE    path to search for backups (two directories deep)
  -h, --help                 show this message and exit

让我们尝试一下:

$ rictl backup info -u 00000000-0000000000000000
UDID: 00000000-0000000000000000
Path: /Users/afit/Library/Application Support/MobileSync/Backup/00000000-0000000000000000
Backup in progress: False
Device name: Aidan's iPhone
Backup display name: Aidan's iPhone
Backup date: 02/07/2019 11:33:41
Backup size: 104258399691 bytes
Backup encrypted: True
Product version: 12.3.1
Product type: iPhone11,6
Serial number: FK1XH•••KPH6
Phone Number: +44 •••• ••••••
ICCID: 894411••••••••••••5
MEID: 35728209••••••

当然,虽然iOS设备的UDID是唯一的,但在您的计算机上可能有多个备份 - 例如,如果您有一个存档备份 - 如下所示:

$ rictl backup search -l | grep B919
DB72CB76A00CB81675F19907D4AC2B298628D83C 09/06/2014 13:57:08 7.1.1 iPhone6,2 ok /Users/afit/Library/Application Support/MobileSync/Backup/backup1
DB72CB76A00CB81675F19907D4AC2B298628D83C 23/07/2014 12:37:55 8.0   iPhone6,2 ok /Users/afit/Library/Application Support/MobileSync/Backup/backup2
DB72CB76A00CB81675F19907D4AC2B298628D83C 28/07/2014 12:43:56 8.0   iPhone6,2 ok /Users/afit/Library/Application Support/MobileSync/Backup/backup3
$ rictl backup info -u DB72CB76A00CB81675F19907D4AC2B298628D83C
Multiple backups found with UDID DB72CB76A00CB81675F19907D4AC2B298628D83C. Use the '--search-path' option to specify the backup's location. This can be shown with the '-l' argument on 'rictl backup search'.

解决方案是什么?通过指定备份所在的文件夹而不是包含备份文件夹的文件夹来缩小搜索路径!

$ rictl backup info -s /Users/afit/Library/Application Support/MobileSync/Backup/backup3 -u DB72CB76A00CB81675F19907D4AC2B298628D83C
UDID: DB72CB76A00CB81675F19907D4AC2B298628D83C
Path: /Users/afit/Library/Application Support/MobileSync/Backup/backup3
Backup in progress: False
Device name: Aidan's iPhone
Backup display name: Aidan's iPhone
Backup date: 28/07/2014 12:43:56
Backup size: 239001214 bytes
Product version: 8.0
Product type: iPhone6,2
Serial number: C7KNG•••G5MV
Phone Number: +44 •••• ••••••
ICCID: 894411••••••••••••5
MEID: 35728209••••••

使用list列出iOS备份中的文件

$ rictl help backup list
Usage: rictl backup list [args]
List files in a backup

Available arguments:
  -u, --udid=VALUE           backup UIUD
  -s, --search-path=VALUE    path to search for backups (two directories deep)
  -p, --password=VALUE       backup password
  -l                         use a long listing format
  -r, --pattern=VALUE        file pattern (regex)
      --allow-in-progress    allow use of in-progress backups
  -h, --help                 show this message and exit

我们来试试吧:

$ rictl backup list -u 00000000-0000000000000000 -r plist$ -l
rw-r--r-- 321   24/06/2019 13:04:37 ManagedPreferencesDomain\mobile\.GlobalPreferences.plist
rw------- 16975 21/06/2019 14:52:54 AppDomainPlugin-com.apple.stocks.widget\Library\Preferences\com.apple.stocks.widget.plist
rw-r--r-- 219   01/07/2019 09:37:24 HomeDomain\Library\UserNotifications\A4CCFF5B-F963-425F-8068-729972F77C67\DeliveredNotifications.plist
...

使用extract从iOS备份中提取文件

$ rictl help backup extract
Usage: rictl backup extract [args]
Extract files from a backup

Available arguments:
  -u, --udid=VALUE           backup UIUD
  -s, --search-path=VALUE    path to search for backups (two directories deep)
  -p, --password=VALUE       backup password
  -o, --output-path=VALUE    path to extract files to
  -r, --pattern=VALUE        file pattern (regex)
      --allow-in-progress    allow use of in-progress backups
  -h, --help                 show this message and exit

让我们将所有.db文件从备份中Extracted到名为Extracted的文件夹,并提供密码的备份password

$ rictl backup extract -u 00000000-0000000000000000 -r "\.db" -o "Extracted" -p "password"
Extracting HomeDomain/Library/Voicemail/voicemail.db
Extracting HomeDomain/Library/Safari/Bookmarks.db
Extracting RootDomain/Library/Caches/locationd/consolidated.db
Extracting WirelessDomain/Library/CallHistory/call_history.db
...

使用export从iOS备份导出数据

$ rictl help backup export
Usage: rictl backup export [args]
Export data from a backup

Available arguments:
  -u, --udid=VALUE           backup UIUD
  -s, --search-path=VALUE    path to search for backups (two directories deep)
  -p, --password=VALUE       backup password
  -t, --type=VALUE           data type (messages, whatsapp, viber, kik, wechat,
                               line, hike, tinder, photos, videos, recordings,
                               contacts, calendar, notes, calls, locations,
                               voicemail)
  -o, --output-path=VALUE    associated file output path
  -r, --pattern=VALUE        search pattern (regex)
  -f, --force                allow overwriting exising files
      --allow-in-progress    allow use of in-progress backups
  -h, --help                 show this message and exit

导出的数据以与ricloud API使用的相同JSON格式提供,这些格式在此处记录

让我们从备份中提取所有消息数据。这些数据将在控制台的标准输出流stdout )上返回,因此我们将其重定向到名为messages.json的文件。我们将所有相关文件保存在名为Associated files的文件夹中,并提供密码的备份password

$ rictl backup export -u 00000000-0000000000000000 -t messages -o "Associated files" -p "password" > messages.json
...
$ cat messages.json
[
  {
    "From": "789789",
    "To": "Me",
    "Date": "2012-12-17T14:12:30Z",
    "Deleted": false,
    "Message": "All done! You're now on our Big Data Texts Tariff. We switched you over on 17/12/12",
    "Attachments": []
  },
  {
    "From": "789789",
    "To": "Me",
    "Date": "2012-12-17T18:12:50Z",
    "Deleted": false,
    "Message": "You have 300 Texts and Unlimited data",
    "Attachments": []
  },
...

使用设备

$ rictl help device
Usage: rictl device <command> [args]
Work with devices over USB and Wi-Fi

Available commands:
  search    Show connected devices over USB and Wi-Fi
  backup    Backup a connected device
  restart   Restart a connected device
  shutdown  Shutdown a connected device

Use 'rictl help device <command>' for detailed help on a particular device command

使用设备时,有四个选项: searchbackuprestartshutdown

rictl添加到您的路径中

iPhone备份提取器可以使用“ Preferences窗格自动将rictl添加到Windows或macOS计算机的路径中,以便可以轻松地在计算机的任何终端中使用它。

iPhone Backup Extractor's "Scripting" preferences pane
iPhone Backup Extractor的“脚本”首选项窗格

但是,您也可以自己设置路径,或使用alias命令。 rictl的功能是通过iPhone Backup Extractor的二进制文件访问的,因为包装脚本显示:

$ cat `which rictl`
#!/bin/bash
/Applications/iPhone\ Backup\ Extractor.app/Contents/MacOS/iPhoneBackupExtractor cli "$@"

文件搜索的常用正则表达式模式

  • 查找以文本plist结尾的路径: -r plist$
  • 查找文件扩展名为.db路径: -r \.db

企业使用

rictl的功能大致遵循 iPhone Backup Extractor 的功能:该工具允许不受限制地操作以探索备份,但每次运行时一次最多只能提取四个文件或导出四项数据。

我们非常希望了解该技术的使用方式,并支持许多已在此技术之上构建内部管理或合规工具或产品的企业。如果这对您有价值,请与我们联系

我们能帮你什么吗?

我们的支持团队在这里提供帮助!

我们的办公时间是格林威治标准时间周一至周五上午9点至下午5点。 时间目前是 2:36 AM的 GMT。

我们力争在一个工作日内答复所有垂询。

我们的支持团队非常棒

我们可以改进这篇文章吗?

我们喜欢听取用户的意见:为什么不给我们发电子邮件,发表评论或发推文 @reincubate?

© 2008 - 2024 Reincubate Ltd. 保留所有权利。 在英格兰和威尔士注册 #5189175, VAT GB151788978. Reincubate®和Camo®是注册商标。 隐私政策 & 条款.