Files
Jellymove/README.md
T
IxianPixel 4c6217bd40
CI / test (push) Successful in 1m18s
Add a Trash view to see and empty .jellymove-trash (#3)
Moved folders sat in each library's .jellymove-trash until removed by hand on the server. The new Trash tab lists them on either server with
size, file count, when and where they went, and empties one item, a library or everything after a confirmation.
- trash.rs: list and empty entries. Entries are referred to by an opaque ID and resolved by scanning; only real folders directly inside a trash folder can be deleted.
- Each move now gets its own trash entry folder, with a small metadata file. Fixes moves failing when the same item had been trashed before.
- Peer API: GET /trash, POST /trash/empty, and /exports/{id}/complete now records the job and destination.
- e2e tests for listing, emptying from either side, refusing paths as IDs, and moving the same item away twice.

Closes #3
2026-11-06 16:30:54 +00:00

205 lines
8.9 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: the **Trash** tab shows what's
waiting on each server, how much space it uses, and empties it when you're
ready.
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.
With Docker, copy [deploy/docker-compose.yml](deploy/docker-compose.yml),
fill in the `environment:` section, fix the volumes and `user:`, then:
```sh
mkdir jellymove-data && sudo chown 1000:1000 jellymove-data # same IDs as user:
docker compose run --rm jellymove check-config # prints the settings, secrets hidden
docker compose up -d
```
Every setting in [config.example.toml](config.example.toml) can be set as
`JELLYMOVE_<KEY>`, with `__` between a section and its key
(`[peer] token` → `JELLYMOVE_PEER__TOKEN`). There's no config file in this
setup, so the "config file not found; using environment only" warning at
start-up is expected. If you'd rather use a file, mount it at
`/config/jellymove.toml`. Environment variables still override it.
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]`, or `JELLYMOVE_UI__USERNAME`/`__PASSWORD`)
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. Gitea won't let the workflow's own token push packages, so the repo
needs two Actions secrets: `REGISTRY_USER` (your Gitea username) and
`REGISTRY_TOKEN` (a personal access token with only package read and write).
The workflow stops straight away if either is missing. 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 from the **Trash** tab 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
- Automatic trash retention (e.g. empty after N days)
- 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.