kei is a command-line tool that backs up iCloud Photos to folders you control. Use it on your computer, server or NAS for a one-time backup or regular automatic syncs.
It supports large libraries, Shared Libraries, albums, Live Photos, RAW files and edited versions. It can resume interrupted downloads and check existing files before downloading them again.
Warning
kei is pre-release software. Minor versions may contain breaking changes.
Read the upgrade checklist for your version and changelog before updating.
- Use macOS, Linux or Windows, or run kei in Docker on a supported computer or NAS. Choose a folder kei can write to, with room for your photos, videos, accompanying files and temporary downloads. For a new backup, start in an empty folder.
- Have your Apple Account password and a trusted Apple device ready for the six-digit 2FA code. SMS-only 2FA, app-specific passwords, and accounts with registered FIDO/WebAuthn security keys are not supported.
- kei requires iCloud Photos web access and Advanced Data Protection (ADP) turned off. Turning off ADP removes end-to-end encryption for Photos and the other data categories it protects; Apple then holds the recovery keys under standard data protection. Read Apple's explanation and kei authentication requirements before deciding. If you want to keep ADP enabled, stop here: kei cannot back up that library. Web access alone does not make ADP compatible.
Already have an icloudpd archive? Start with Migrating from icloudpd, including the import preview and path checks, before pointing kei at it.
On macOS with Homebrew:
brew install rhoopr/kei/keiFor macOS, Linux or Windows without Homebrew, download the matching file from Releases, unpack it, and put kei in a folder on your PATH so you can run it from a terminal. Check the installed version with kei --version. Instructions for building from source and using FreeBSD are in Install.
Follow First backup with Docker to set up folders that survive container replacement, save your settings, sign in and try a small backup. Run those commands on the machine running Docker. The commands below assume kei is installed directly on your computer.
For a new installation on your computer, run:
kei config setupChoose an empty destination such as ~/Photos/kei-first-backup, your main library, and Manually when needed. Save a small fixed capture-date range containing photos you recognize. Check the selected albums, file types and destination folders before saving. Answer no to the final sync prompt to review the config before starting. On this branch, no is the default. In v0.26.0 the default is yes. Leaving before the write discards the wizard answers.
If you choose watch mode instead, the setup wizard still runs only once. Later kei sync commands can use the repeat interval you saved.
The setup wizard writes config.toml under the kei directory described below and offers to save your login details. If it creates an environment file, follow the printed instructions to load it before the next command. Then try a small backup. Replace both example dates below with your own small range; the dates are inclusive and use each photo's capture-local calendar date:
kei sync --skip-created-before 2025-01-01 --skip-created-after 2025-01-07
kei statusApprove the sign-in prompt on your trusted Apple device and enter the six-digit code when asked.
The range limits capture dates, not file count. Album copies, Live Photo videos and additional versions can produce several files per item. A busy date range can still download many files. This is only a sample of your library.
- Read the sync summary and warnings. Failed or unfinished work still needs attention, even if some files downloaded successfully.
- Open the destination in your file manager. Look for the recent photos you expected in the album and date folders, and open a photo and video if you selected both. Live Photos normally include a still image and a MOV video.
- Run
kei statusto check recorded progress. It does not inspect the files or determine whether your selection covers all of iCloud. Runkei verify --checksumsto compare saved files with their recorded local checksums. A present file without a baseline has not been checksum-verified. A difference may be an intentional edit.
Photos are saved in the folder set by [download].directory. On a fresh install, kei uses $XDG_CONFIG_HOME/kei if XDG_CONFIG_HOME is an absolute path. Otherwise it uses ~/.config/kei. If only the legacy ~/.config/kei directory exists, kei keeps using it. If both directories exist and point to different locations, automatic discovery stops and lists both. Inspect them before moving anything.
--config overrides KEI_CONFIG; both select the config file only. For saved logins and backup state, KEI_DATA_DIR overrides the config's data_dir. Without either, kei uses cookies/ under the discovered kei directory. To run with two separate roots present, select both a config and a state directory explicitly. Keep the state as well as your photos and videos. If you manage custom paths, uninstall without --purge and review those files before removing them.
For example, to inspect the legacy config if you used its default state location:
KEI_DATA_DIR="$HOME/.config/kei/cookies" kei --config "$HOME/.config/kei/config.toml" config showBy default, kei downloads available full-resolution originals, current edits and RAW/JPEG renditions, including both Live Photo components. Use [filters].exclude to omit ordinary photos, ordinary videos, Live Photo stills or Live Photo videos. Existing configurations need an explicit rendition-policy migration. See example.config.toml.
Album selectors in [filters].albums match provider names before filesystem sanitization. albums = ["Trips"] selects every album named Trips; albums = ["Family/Trips"] selects that qualified album path. Exclusions use the same rules, so albums = ["all", "!Trips"] excludes every matching leaf. The {album} template token preserves the folder hierarchy, with each path component sanitized separately. Unknown selectors and ambiguous qualified paths fail.
Once the small backup looks right, review your saved choices before expanding them. Widen or remove the saved date bounds only when you want to include more dates. kei sync without date flags uses the saved bounds, so it can still repeat only the sample. The setup wizard can select all available libraries, including Shared Libraries. Check albums, smart folders, photos outside albums and component exclusions before treating the result as a full backup.
As an alternative to the wizard, a minimal config for this development branch is below. Released v0.26 builds use the v0.26 instructions and do not accept config_version.
config_version = 1
[auth]
username = "you@example.com"
[download]
directory = "~/Photos/iCloud"This has no date limit: it selects your primary library, all its regular albums, and photos and videos outside those albums. Save your chosen date bounds if you still want only a sample. To limit one run, use kei sync --skip-created-before 2025-01-01 --skip-created-after 2025-01-07, replacing both example dates with your own range. Both dates are inclusive.
Sync and service mode no longer accept --recent, --recent-scope, or [filters].recent / recent_scope. Remove both saved keys and any old flags. To keep sync bounded, choose fixed skip_created_before / skip_created_after dates instead; relative values such as 30d are also rejected. These errors explain the supported replacement and stop before authentication or state/media changes, even when a CLI value would override a retired saved setting. Kei does not rewrite your config or silently expand the selection. The separate import-existing --recent 100 sampling option still accepts positive counts; import does not gain date filtering.
For a daily unattended run, add this table to your existing config:
[watch]
interval = 86400kei service run keeps running in your terminal; kei install sets up a background service on your computer. Follow Service mode and Authentication for startup, saved login details and what to do when Apple asks you to sign in again. Docker users should finish the container guide.
If a sync fails, check that kei can write to the destination, that there is enough free space, and that you selected the library and albums you intended. Check the sign-in requirements too. The Status and Doctor guides explain how to check your setup.
For a bug or confusing result, open an issue with your kei version, what you expected and what happened. When available, run kei support-export --output kei-support.json with the same configuration and data directory. It collects details already saved by kei without another sync and uploads nothing automatically. Review the file before attaching it. You can still report a problem if you're using an older version or the export is incomplete. See Support export for details and Docker instructions.
Some repair commands change kei's saved state or replace files. Read Backup maintenance first. Don't delete state or conflicting files just to clear a warning. Sync never deletes files, and it replaces a file only while the file still holds the bytes kei recorded for it.
v0.30 replaces the sync engine. The first sync carries over the copies your previous state recorded and lists every library from the start; see Upgrade and compatibility. Legacy coverage certificates, trust declarations and the hardlink waiver no longer apply; see retired maintenance.
- Downloads several files at once, resumes interrupted transfers, and checks downloaded data before marking a file complete.
- Saves ordinary photo and video files without needing an Apple Photos library, arranged by album and date as you choose.
- Supports Shared Libraries, Live Photos, current edits and available RAW/JPEG renditions.
- Runs once or on a schedule, in Docker or as a background service on Linux, macOS or Windows.
- Provides progress reports, troubleshooting tools, file lists, backup checks, repair commands and import of existing files.
Kei automatically saves photo information in its own database. Setup enables standard embedded metadata through explicit saved settings. Existing omitted settings and runs without a config keep metadata output disabled. Sidecars, album names and people remain optional. See Metadata output for supported formats, update permissions and timestamp repair.
- Install
- Upgrade and compatibility
- Account state migration
- Backup maintenance
- Metadata output
- Choose which rendition gets the original filename
- Configuration
- Docker
- Service mode
- Commands
- Credentials
- Status
- Doctor
- Manifest export
- Product charter
- Planned work
Report bugs or confusing behavior in Issues.
MIT - see LICENSE
kei's iCloud support builds on reverse-engineering from icloud-photos-downloader. kei was originally published as icloudpd-rs before broadening beyond iCloud Photos.
