Skip to main content

🗂️ partial-backup: Metadata-Aware Partial Backup Creator

This utility scans a given directory in a structured "unbacked" format and generates a Backup object that can be written back as a valid backup. It preserves directory and file metadata such as ownership (user_), group (group_), and file mode (mode_), and skips common junk files.


📦 Features

  • Recursively scans a directory organized by domain (e.g., HomeDomain)
  • Supports embedded metadata in directory names (user_501_group_0_mode_755)
  • Preserves and serializes:
    • File contents
    • Directory structure
    • Ownership and permissions
  • Skips system-specific noise like .DS_Store and Thumbs.db
  • Outputs a fully reconstructable Backup object
  • Simple CLI using Typer

🛠️ Installation

pip install partial-backup

🧪 Example Usage

Assume your source directory is structured like this:

unback/HomeDomain/
└── Library
    └── Preferences/
        └── com.example.settings.plist

To generate the backup:

partial-backup unback/ output/

It will:

  • Detect HomeDomain
  • Extract user/group/mode/protection class from directories like user_501_group_0_mode_755
  • List every parent directory, including the domain root, so the device can create them
  • Write an iOS 10+ backup (Manifest.db) into output/partial-backup/

Matching the device exactly

The device applies the owner, mode and data protection class listed in the backup, including to directories that already exist. The built-in defaults follow a real iOS 27.2 backup, but for exact values take a small backup of the same area from the target device and pass it as a reference:

pymobiledevice3 backup2 backup bk/ --full --only sms
partial-backup unback/ output/ --reference bk/<UDID>

Entries present in the reference keep its attributes (explicit metadata hints still win), and the device's own Info.plist/Manifest.plist metadata and keybag are reused.

♻️ Restore the Backup

The generated backup is compatible with pymobiledevice3, and can be restored to an iOS device without a full erase. Installed apps stay installed:

pymobiledevice3 backup2 restore output/ --source partial-backup --no-copy --system --no-remove --skip-apps
  • --system is required unless --reference was used: HomeDomain, MediaDomain and the other domains in the device's MobileBackup.framework/Domains.plist are "system domains", and the device skips them unless the host asks for system files or the backup's Lockdown.DeviceClass matches the device.
  • The device restores only what its Domains.plist allows. Paths outside a domain's rules (e.g. anything in MediaDomain other than its RelativePathsToBackupAndRestore, such as Media/Recordings or Library/SMS/Attachments) and some whole domains (e.g. SysSharedContainerDomain-systemgroup.com.apple.configurationprofiles) are skipped silently: the restore still reports success.
  • App containers (AppDomain-<bundle id>, AppDomainGroup-<group id>, AppDomainPlugin-<bundle id>) of installed apps are restored too; their identifiers are listed in Manifest.plist's Applications automatically, since the device skips app domains that aren't listed there. A container of an app that isn't installed is set aside in /var/mobile/Library/SafeHarbor instead.
  • The device reboots when done and shows the post-restore Setup Assistant screens; backups are refused (MBErrorDomain/212) until they are completed. --no-reboot doesn't avoid this, it only postpones it. Developer Mode is turned off; re-enable it with pymobiledevice3 amfi enable-developer-mode.

For iOS 9 and older, --legacy writes the old Manifest.mbdb format directly into output/.

📁 Metadata Syntax

This tool supports optional metadata hints in folder names:

Syntax Meaning
user_501 File owned by user 501
group_20 File belongs to group 20
mode_755 File or directory mode
class_4 Data protection class
user_501_group_20_mode_644_class_3 All of the above

These metadata markers are automatically removed from paths and applied to the entries below them. Without hints, files are 0644, directories 0755, files use protection class 3, and the owner is mobile (501) for domains under /var/mobile (HomeDomain, AppDomain-*, ...) and root otherwise.

⛔ Ignored Files

The following files and folders are skipped automatically:

  • .DS_Store
  • Thumbs.db
  • desktop.ini
  • .Spotlight-V100
  • .Trashes

API Overview

from pathlib import Path
from partial_backup.backup import Backup

backup = Backup.create_backup_from_directory(Path('/path/to/unback'))
backup.write_to_directory(Path('/path/to/output'))  # -> /path/to/output/partial-backup

🙏 Acknowledgments

Huge thanks to @JJTech0130 for his insights and foundational work on the backup DB implementation.

Metadata

Release files for partial-backup 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for partial-backup 0.1.1
File Size Uploaded Provenance Actions
partial_backup-0.1.1.tar.gz 23.6 kB With provenance Details for partial_backup-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for partial-backup 0.1.1
File Interpreter ABI Platform Actions
partial_backup-0.1.1-py3-none-any.whl Python 3 none any Details for partial_backup-0.1.1-py3-none-any.whl

Total release size: 37.7 kB

Release files / partial_backup-0.1.1.tar.gz

Download URL partial_backup-0.1.1.tar.gz
Size 23.6 kB
Tags Source
SHA-256 checksum
How to use checksums
00308be769bc83ae05ab94006d051e927a5d03ffe2ef5dd64657e5921fada873
BLAKE2b-256 checksum
How to use checksums
1bcc3bc3734eb87c7ee1314c7ba608733bac17bab77ed246102001bf160f343d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

Release files / partial_backup-0.1.1-py3-none-any.whl

Download URL partial_backup-0.1.1-py3-none-any.whl
Size 14.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4931e5b199c0aac84bc80aac15bb6d5ca3ded2f5d83aecdb54db84056509febd
BLAKE2b-256 checksum
How to use checksums
a1c26d3997be501fc36c93459e894dfdcd431f3cb1fa0c9e7832fa39588c1951
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

Security for partial-backup 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for partial_backup-0.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page