ydiskarc (pronounced Ai-disk-arc) is a command line tool used to backup Yandex.Disk public resources. Public resources are only shared files and folders from Yandex.Disk service. Yandex provides a free-to-use API that allows downloading the data.
- Metadata extraction — automatically saves metadata as
_metadata.jsonfiles. - Download any public resource — single files or entire directory trees.
- Resume support — interrupted downloads continue from the last byte (
.partfiles). - Retry logic — transient network failures are handled automatically with exponential backoff.
- Rate limiting handling — the tool waits and retries on
429 Too Many Requests. - Parallel transfer —
--parallel Ndispatches file downloads through a thread pool. - Progress tracking — visual progress bars for downloads via
tqdm. - Pre-download statistics — total file count and estimated size are printed before the run starts.
- Quiet by default — logs only appear when verbose mode is enabled; no process-global logging side-effects.
- Update mode —
--updateskips files that already exist. - Path-traversal safe — hostile
..segments in API paths are rejected viasafe_join. - RFC 6266 / 5987 filenames — server-supplied filenames are decoded correctly and sanitized.
- Configurable TLS — point at a custom CA bundle via
YDISKARC_TLS_VERIFYfor corporate proxies.
A universal installation method (that works on Windows, macOS, Linux, …) is pip:
# Make sure we have an up-to-date version of pip and setuptools:
$ pip install --upgrade pip setuptools
$ pip install --upgrade ydiskarcIf pip installation fails for some reason, easy_install ydiskarc is a fallback.
Python version 3.9 or greater is required. The project is tested against 3.9, 3.10, 3.11, and 3.12 on Linux, macOS, and Windows in CI.
Synopsis:
$ ydiskarc [command] [URL] [flags]Examples:
# Sync command — URL is a positional argument
$ ydiskarc sync https://disk.yandex.ru/d/ABC123 -o output
# Full command — URL is a positional argument
$ ydiskarc full https://disk.yandex.ru/i/XYZ789 -o output
# Parallel sync — download up to 8 files concurrently
$ ydiskarc sync https://disk.yandex.ru/d/ABC123 -o output --parallel 8See also python -m ydiskarc and ydiskarc [command] --help for help on each command.
Synchronizes files and metadata from a public directory resource to a local directory. Maintains the directory structure and saves metadata for each directory level.
Basic usage:
$ ydiskarc sync https://disk.yandex.ru/d/VVNMYpZtWtST9Q -o mos9maystyleUpdate mode (only download files that don't already exist locally):
$ ydiskarc sync https://disk.yandex.ru/d/VVNMYpZtWtST9Q -o mos9maystyle --updateMetadata only (no file downloads):
$ ydiskarc sync https://disk.yandex.ru/d/VVNMYpZtWtST9Q -o mos9maystyle --nofilesParallel downloads:
$ ydiskarc sync https://disk.yandex.ru/d/VVNMYpZtWtST9Q -o mos9maystyle --parallel 8Options:
URL— public resource URL (required, positional argument).--output,-o— output directory (defaults to the resource ID).--update— only download files that don't exist locally.--nofiles,-n— metadata-only mode; save metadata without downloading files.--parallel,-pN— number of concurrent file downloads (default1, sequential).--verbose,-v— enable verbose logging (logs are hidden by default).
The command displays total file count and estimated size before starting downloads.
Downloads a single file or a directory. Single files are downloaded with their original format.
Directories are downloaded as ZIP files containing all files inside. For single-file resources, the tool short-circuits the second API call when the metadata response already contains the direct file URL.
Basic usage:
$ ydiskarc full https://disk.yandex.ru/i/t_pNaarK8UJ-bQ -o filesWith metadata:
$ ydiskarc full https://disk.yandex.ru/i/t_pNaarK8UJ-bQ -o files -mVerbose output:
$ ydiskarc full https://disk.yandex.ru/i/t_pNaarK8UJ-bQ -o files -v -mOptions:
URL— public resource URL (required, positional argument).--output,-o— output directory.--filename,-f— output filename (defaults todump.zip).--metadata,-m— extract and save metadata as_metadata.json.--verbose,-v— enable verbose logging.
Notes:
- Single files are downloaded with their original format.
- Directories are downloaded as ZIP files (default filename:
dump.zip). - The command displays file count and size information before downloading.
Persists a Yandex OAuth key to .ydiskarc with restricted file permissions.
$ ydiskarc configure --key YOUR_OAUTH_KEYThe resulting .ydiskarc file is created with mode 0o600 on POSIX systems so the OAuth token is not world-readable. Existing fields in the file are preserved.
Options:
--key,-kKEY— the OAuth token to persist (required).--projectdir,-pDIR— directory in which to write.ydiskarc(defaults to the current directory).--verbose,-v— enable verbose logging.
Add .ydiskarc to your .gitignore — the file contains a secret.
Prints the installed version:
$ ydiskarc version| Variable | Effect |
|---|---|
YDISKARC_TLS_VERIFY |
Path to a custom CA bundle for TLS verification, 1/0 to enable/disable verification. See TLS verification. |
By default ydiskarc verifies TLS using the system trust store. Behind a corporate proxy with a private CA, point at the CA bundle:
$ export YDISKARC_TLS_VERIFY=/etc/pki/corporate-ca.pem
$ ydiskarc sync https://disk.yandex.ru/d/X -o outTo disable verification (not recommended):
$ export YDISKARC_TLS_VERIFY=0.ydiskarc is a YAML file. The ydiskarc configure command writes one with POSIX 0o600 permissions:
keys:
yandex_oauth: your_oauth_key_hereThe token is currently reserved for future use (the public API endpoints used by ydiskarc do not require authentication).
ydiskarc follows a modular structure so each concern is in one place:
ydiskarc/
├── __init__.py package metadata (__version__, __all__)
├── __main__.py `python -m ydiskarc` entry point
├── client.py YandexDiskClient: HTTP session, retry, rate-limit, URL validation
├── downloader.py ResourceDownloader: streaming, .part, resume, RFC 5987 filenames
├── models.py Dataclasses for the Yandex.Disk API JSON shape
├── config.py Config dataclass: API URLs, timeouts, retries, pool size, TLS verify
├── constants.py Named constants (HTTP status codes, JSON keys, filenames)
├── core.py Typer commands (thin wrappers around Project)
└── cmds/
├── __init__.py re-exports Project
└── processor.py Project facade + recursive walker (safe_join, PathTraversalError)
The Project class is the single public entry point for the recursive walker logic. Recursive functions live as private helpers (_yd_get_full, _yd_get_and_store_dir, _scan_directory_for_stats); they cannot be imported directly. The Typer commands in core.py instantiate Project and delegate.
See openspec/specs/core-architecture/spec.md for the authoritative behaviour specification.
"No download url. Probably wrong public url/key?"
- Verify the URL is correct and the resource is publicly accessible.
- Check that the URL format matches:
https://disk.yandex.ru/d/...orhttps://disk.yandex.ru/i/....
"Failed to download file" or network errors
- Check your internet connection.
- The tool automatically retries on transient failures.
- For rate limiting, the tool will wait and retry automatically based on
Retry-After.
"Failed to create directory"
- Check file system permissions.
- Ensure you have write access to the output directory.
Resume interrupted downloads
- Downloads automatically resume if interrupted.
- Partial files are detected and resumed from the last byte (HTTP
Range:request).
By default, ydiskarc runs quietly and only shows progress bars and essential information. For detailed debugging information, use the --verbose / -v flag:
$ ydiskarc sync https://disk.yandex.ru/d/... -o output -vWhen verbose mode is enabled:
- Detailed logging of all operations (on the
ydiskarcpackage logger; other libraries' logs are not muted). - File-by-file download progress.
- API request details.
- Error stack traces.
Download a public folder:
$ ydiskarc sync https://disk.yandex.ru/d/ABC123 -o my_backupParallel sync of a large folder:
$ ydiskarc sync https://disk.yandex.ru/d/ABC123 -o my_backup --parallel 8Download a single file with metadata:
$ ydiskarc full https://disk.yandex.ru/i/XYZ789 -o downloads -mUpdate existing backup (skip existing files):
$ ydiskarc sync https://disk.yandex.ru/d/ABC123 -o my_backup --updateGet metadata only:
$ ydiskarc sync https://disk.yandex.ru/d/ABC123 -o metadata_only --nofilesExample output:
Total files to download: 7
Total size: 10.12 MB
Downloading file1.pdf: 100%|████████████| 1.72M/1.72M [00:05<00:00, 345KB/s]
Downloading file2.pdf: 100%|████████████| 980K/980K [00:03<00:00, 290KB/s]
...
The repository uses Dependabot to open weekly pull requests for outdated pip and GitHub Actions dependencies. A pip-audit Software Composition Analysis (SCA) job runs on every CI build to detect known vulnerabilities in the dependency tree. PRs that introduce vulnerable dependencies fail the build.
Contributions are welcome! Please follow these guidelines:
-
OpenSpec first. Non-trivial changes (new features, breaking changes, architecture shifts) MUST start as an OpenSpec proposal under
openspec/changes/<id>/. See openspec/AGENTS.md for the workflow. -
Fork the repository and create a feature branch.
-
Write tests for every new public helper or command.
-
Follow code style — the project uses:
blackfor formatting (line length: 100)flake8andrufffor lintingisort(--profile black) for import orderingmypyfor type hints (best-effort,--ignore-missing-imports)
-
Run the full check suite before submitting:
pip install -r requirements-dev.txt pytest --cov=ydiskarc --cov-fail-under=70 black --check --line-length=100 ydiskarc tests isort --check-only --profile black --line-length 100 ydiskarc tests flake8 ydiskarc tests --max-line-length=100 --extend-ignore=E203,W503
-
Install pre-commit hooks (recommended):
pip install pre-commit pre-commit install
-
Submit a pull request with a clear description and a link to the OpenSpec change.
# Clone the repository
git clone https://github.com/ruarxive/ydiskarc.git
cd ydiskarc
# Install in development mode
pip install -e .
# Install development dependencies
pip install -r requirements-dev.txt
# Run tests with coverage
pytest --cov=ydiskarc --cov-report=term-missing
# Run linting
flake8 ydiskarc tests --max-line-length=100 --extend-ignore=E203,W503
ruff check ydiskarc tests
black --check --line-length=100 ydiskarc tests
isort --check-only --profile black --line-length 100 ydiskarc tests
# Run mypy (best-effort)
mypy ydiskarc --ignore-missing-importsReleases are published to PyPI automatically when a maintainer pushes a tag matching v*.*.* (e.g. v1.2.0). The release workflow uses OIDC trusted publishing — no long-lived PyPI token is needed.
Manual release steps for maintainers:
- Bump
__version__inydiskarc/__init__.py. - Add a release entry to
CHANGELOG.mdunder a new[X.Y.Z]heading, moving the[Unreleased]items into it. - Commit and push:
git commit -am "Release vX.Y.Z"thengit tag vX.Y.Z && git push --tags. - Watch the
Releaseworkflow on GitHub Actions.
For detailed information about the Yandex.Disk API metadata structure:
- Examples Directory — contains example metadata file and documentation.
- Metadata Structure Documentation — complete reference of metadata fields.
See CHANGELOG.md for a detailed list of changes.
This project is licensed under the MIT License — see the LICENSE file for details.
- Repository: https://github.com/ruarxive/ydiskarc/
- Issues: https://github.com/ruarxive/ydiskarc/issues
- Changelog: https://github.com/ruarxive/ydiskarc/blob/main/CHANGELOG.md
- Yandex.Disk API: https://yandex.com/dev/disk/api/