Files
Jellymove/README.md
T
IxianPixel 577715bb40
CI / test (push) Successful in 2m20s
Release / release (push) Successful in 10m28s
Prepared things for Docker
2026-11-06 12:10:53 +00:00

189 lines
8.0 KiB
Markdown

# jellymove
Move movies and TV series between two Jellyfin servers, with their subtitles,
artwork, NFOs, extras and everyone's watch history.
Built for a two-tier setup: a cloud server with fast but limited storage and
a home server with slow but large storage, presented as one library by
[Jellyswarrm](https://github.com/LLukas22/Jellyswarrm). Pick a film or series
in the web UI and send it to the other side. jellymove copies it, checks it,
gets the other Jellyfin to index it, carries the watch state across, and only
then removes it from the source.
> **Status: early (v0.1).** The whole move flow works end to end against a
> test double of Jellyfin. It has **not yet been run against a real Jellyfin
> server**. Try a dry run first, keep backups, and read "Not yet verified" below.
## How a move works
One agent runs next to each Jellyfin and sees the same media folders. The
**destination pulls**:
1. **Plan.** The source checks that the item has its own folder, hashes every
file (BLAKE3) and records each user's played state, resume points and
favourites. The destination picks a library and refuses if the folder
already exists. *Dry runs stop here.*
2. **Copy.** Files stream into a hidden `.jellymove-partial/` folder inside the
destination library. Dropped connections resume from where they stopped,
and each file is hash-checked.
3. **Promote.** Verified files are renamed into place, an atomic operation on
the same filesystem.
4. **Index.** The destination asks Jellyfin to scan that folder, then waits
until the item and every episode appear.
5. **Restore watch history.** Jellyfin gives moved files new item IDs, so
jellymove re-applies each user's data to the new items, matching users by name.
6. **Clean up.** The source moves its folder to `.jellymove-trash/` in the same
library and rescans. It is not deleted.
A crash or restart at any point resumes from the last completed step.
## Quick look (no Jellyfin needed)
```sh
npm --prefix ui ci && npm --prefix ui run build
cargo run -p jm-server --example demo
# open http://127.0.0.1:8097 (cloud) and http://127.0.0.1:8098 (home)
```
## Running it for real
Install one agent per server. **Mount media at the same paths as the Jellyfin
container**, so the paths Jellyfin reports are the paths jellymove sees.
```sh
cp config.example.toml jellymove.toml # edit: node_name, jellyfin.api_key, peer.url, peer.token
docker compose -f deploy/docker-compose.yml up -d
```
Each release publishes an image (x86_64) to the Gitea container registry:
`git.malgra.com/ixianpixel/jellymove:<version>`, and `:latest` for anything
that isn't a pre-release. It's the same static binary as the systemd tarball,
on Alpine. If the package isn't public, log in once with a Gitea token that
only has `read:package`:
```sh
docker login git.malgra.com
```
To upgrade, run `docker compose pull && docker compose up -d`.
- Create an admin API key in Jellyfin (Dashboard → API Keys). jellymove reads
every user's watch state.
- Use the same `peer.token` on both agents (`openssl rand -hex 32`).
- The agents talk over HTTP, and **each must be able to reach the other**: the
destination pulls, so a move *to* the cloud needs the cloud agent to reach
home. Put them on Tailscale/WireGuard (simplest), or behind your reverse
proxy with TLS. An outbound-only mode for a home server behind NAT is on
the roadmap.
- Run the container as the same user as Jellyfin (`user: "1000:1000"`) so
moved files keep the right ownership.
- Set a UI password (`[ui]`) unless the port is only reachable privately.
- The **Status** tab checks that every library folder is visible and writable.
### Without Docker (systemd)
Each release has a static Linux binary (x86_64, musl, web UI built in), so it
runs on any distro with no other dependencies:
```sh
tar -xzf jellymove-v0.1.0-x86_64-unknown-linux-musl.tar.gz
cd jellymove-v0.1.0-x86_64-unknown-linux-musl
sudo install -m 755 jellymove /usr/local/bin/jellymove
sudo install -D -m 640 -g jellyfin config.example.toml /etc/jellymove/jellymove.toml
sudo cp jellymove.service /etc/systemd/system/
sudo systemctl daemon-reload && sudo systemctl enable --now jellymove
```
Before starting it, edit `/etc/jellymove/jellymove.toml` and set
`data_dir = "/var/lib/jellymove"` (the unit's `StateDirectory`). If Jellyfin
runs as a different user, change `User=`/`Group=` in the unit and `-g` above.
To upgrade, replace `/usr/local/bin/jellymove` and run `sudo systemctl restart jellymove`.
Interrupted transfers resume after a restart.
### Making a release
`.github/workflows/release.yml` runs on Gitea Actions. To cut a release:
1. Bump `version` in the root `Cargo.toml`.
2. Add a `## v0.1.1` section to the top of `CHANGELOG.md`, using whichever of
`### Added`, `### Updated`, `### Fixed` and `### Removed` apply.
3. Commit, then push a matching tag:
```sh
git tag v0.1.1 && git push origin v0.1.1
```
The workflow runs the tests, builds the UI and binary, attaches the tarball
and its `.sha256` to a Gitea release for that tag, then pushes the Docker
image. It builds the image with `crane`, so the runner needs no Docker
socket. It pushes with the workflow's own token; if Gitea refuses that, add
`REGISTRY_USER` and `REGISTRY_TOKEN` (`write:package`) secrets. The release notes
are that version's section of `CHANGELOG.md`; the workflow stops straight
away if there isn't one. Re-running it replaces the files and refreshes the
notes. Tags with a `-` (`v0.2.0-rc1`) are marked pre-release.
### Library mapping
By default an item goes into the library with the same name on the other
server. To file things elsewhere, configure this on the **receiving** agent:
```toml
[incoming_libraries]
"Movies" = "Movies (archive)"
```
### Jellyswarrm
While a move is running the item exists on both servers, and Jellyswarrm
v0.3.1+ shows it once with two versions. Jellyswarrm's merge cache can go stale
when files move ([#216](https://github.com/LLukas22/Jellyswarrm/issues/216)).
Until that is fixed upstream, restart Jellyswarrm after a move if the merged
view looks wrong. A post-move hook can do it for you:
```toml
[hooks]
post_move = "docker restart jellyswarrm"
```
The hook runs with `sh -c` on the **receiving** agent, so it only helps if
Jellyswarrm runs on that machine. The Docker image has a shell but no Docker
CLI, and mounting `/var/run/docker.sock` gives the container root on the
host. Prefer a socket proxy that only allows restarts, or restart by hand.
## Safety rules
- Nothing leaves the source until the destination has indexed every file.
- The source copy goes to `.jellymove-trash/`. Empty it yourself once you're
happy (automatic retention is on the roadmap).
- Nothing at the destination is ever overwritten.
- A movie must be in **its own folder**. jellymove refuses flat folders like
`Movies/Heat.mkv` + `Movies/Ronin.mkv`, because moving "the folder" would take both.
- Peers can only fetch files the source has explicitly exported, by index.
## Not yet verified
- Against real Jellyfin, in particular user-data writes
(`POST /UserItems/{id}/UserData`), `/Library/Media/Updated` timing on large
libraries, and multi-version movies.
- Against real Jellyswarrm.
- Running the published Docker image, and building from the `Dockerfile`.
The image's contents and config are checked, but it hasn't been started yet.
- Windows and macOS. The code is cross-platform, but only Linux has been run.
## Roadmap
- Season-level moves; "promote" (pre-warm) shortcuts
- Trash retention and a trash view in the UI
- Pairing codes and pinned TLS instead of a shared token
- Outbound-only control channel so a NATed home agent needs no inbound port
- Automatic tiering rules ("demote anything unwatched for 90 days when the cloud disk is over 80%")
- Sonarr/Radarr root-folder updates so the *arrs follow the move
- iroh transport (built-in NAT traversal); scheduled bandwidth windows
- `jellymove service install` (systemd/launchd/Windows service)
## Development
See [CLAUDE.md](CLAUDE.md) for layout, commands and invariants, and
[docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) for the design.