Skip to main content

Basic usage

A backup project is a directory containing an API definition and the local state needed to collect it repeatedly. Run commands inside that directory, or select it with -p / --projectpath. The CLI command prefix can also be written as python -m apibackuper when you need to select a specific Python environment.

For a first successful collection, use the Quick Start. This page explains the same workflow for a project you will maintain.

Create a project and supply the configuration​

From a parent directory:

apibackuper create catalog
cd catalog

create writes a minimal legacy apibackuper.cfg. It is a scaffold, not a complete API definition. Add apibackuper.yaml using a template or the REST walkthrough, and set the actual endpoint, request method, pagination and response keys.

Configuration search order is:

  1. apibackuper.yaml
  2. apibackuper.yml
  3. apibackuper.cfg

The first format found takes precedence; files are not merged. Editing an INI file while YAML exists therefore does not change the active project definition. YAML is recommended; INI is deprecated and produces a validation warning.

Know which files serve which purpose​

A project using defaults can contain:

catalog/
apibackuper.yaml
params.json # optional fixed parameters / POST JSON body
headers.json # optional request headers
url_params.json # optional URL parameters for supported query modes
follow_params.json # optional fixed detail-request parameters
apibackuper_state.json # last successful run and update watermark
apibackuper_checkpoint.json # interrupted/completed run recovery information
storage/
storage.zip # default published main backup
details.zip # only after unnamed follow collection
files.zip # only after ZIP-output attachment downloads

Do not create empty state or checkpoint files manually. Commands maintain them. .partial storage and matching ZIP .journal directories can also exist while a collection is unfinished. Keep them for recovery rather than deleting them as scratch data. Main archive, details, attachment bytes and exports are separate artifacts; one successful stage does not run the others automatically.

Use a project path without changing directories​

These commands run from the parent of catalog:

apibackuper validate-config --strict -p catalog
apibackuper run full --dry-run -p catalog
apibackuper estimate full -p catalog
apibackuper run full -p catalog
apibackuper info --json -p catalog
apibackuper export catalog.jsonl -p catalog

The export is catalog.jsonl in the current directory, beside the project. -p selects a configuration directory; it does not change the process working directory. Put command-specific options after the command, and quote paths with spaces, for example -p "API backups/catalog".

PathResolution rule
Config and JSON request filesInside the selected project
Relative storage.storage_pathInside the selected project
Default state/checkpoint pathsInside the selected project
Explicit state/checkpoint overridesAs written, relative to process working directory
Relative token/password files and settings.logfileProcess working directory
Export filenameProcess working directory

For scheduled jobs, use a known working directory and absolute secret/state paths where needed. See configuration paths.

Follow the collection lifecycle​

StepCommandNetwork and purpose
Check configurationvalidate-config --strictOffline schema/project checks; warnings fail too
Preview executionrun full --dry-runOffline plan from configuration and saved state
Sample the APIestimate fullLive request; requires usable record-count metadata
Collect pagesrun fullLive backup with staged full publication
Inspect saved stateinfo --jsonLocal project/storage report
Export recordsexport catalog.jsonlLocal extraction from retained pages/details

An API without a usable total may still be collectable with page-count or short-page stopping, even when estimate cannot compute its total. A dry-run also does not test credentials or response keys against the live service.

detect can suggest response/pagination keys for an existing project:

apibackuper detect

It makes a live request. Review suggestions before using --write-config; it cannot establish stable ordering, meaningful modification fields or deletion semantics. See detect.

Choose the right recovery or refresh command​

Your intentCommandRequired context
New complete replacementrun fullValid project; preserve an old snapshot if needed
Finish an interrupted full runrun full --resumeSame mode/path and valid checkpoint/staging
Fill missing pages in published storagerun continuePublished flat-page sequence; no record-level freshness check
Legacy name for the previous operationrun incrementalSame behavior as continue
Collect changed recordsupdateSuccessful baseline and API-supported watermark filter
Finish an interrupted updateupdate --resumeIts original generation and checkpoint

A fresh full backup replaces the published main archive only after success. Updates retain generations and repeated IDs; they do not produce a deduplicated current table. A completed checkpoint makes --resume report that the run is already complete. See incremental and update.

After a failure, use the latest command's exit status and logs. info may still show the earlier successful run because failure does not advance successful state. Do not start another fresh run merely because saved state says success.

Export locally and preserve the source​

apibackuper export catalog.jsonl
apibackuper export catalog.jsonl.gz
apibackuper export selected.jsonl --fields id,title --where "id >= 3"

Choose fields and types from your records; the numeric-ID filter is illustrative. Export defaults from the suffix (.jsonl, .gz, .zst, .parquet) or an explicit --format. .json also means JSON Lines, not a single array. Parquet requires optional dependencies.

Keep output outside source storage; filesystem backups reject exports inside their own root. Export replaces existing output only after successful writing. Filtering accepts one comparison, not SQL/logical expressions. See export and storage.

Add details or attachments only when configured​

For a project with an unnamed follow rule:

apibackuper follow full --dry-run
apibackuper follow full
apibackuper getfiles

follow requires its own identifier/URL settings. getfiles requires a files section and ZIP main storage. With follow configured, it reads unnamed details rather than falling back to list pages. An existing unnamed details.zip is also selected by export, so refresh details deliberately after new list backups. See follow and files.

Get help and diagnostics​

apibackuper --help
apibackuper run --help
apibackuper export --help
FlagAvailable on
-p / --projectpathProject commands; create uses a positional destination
-v / --verbosecreate, detect, run, update, export, validate-config
--dry-runrun, update, follow; run also has the alias --profile
--resumerun, update; follow recovery uses follow continue
--strictvalidate-config

The default log is apibackuper.log in the process working directory; the project can set settings.logfile. Verbose output adds console diagnostics on supported commands. Check troubleshooting when a command fails, and best practices before turning the project into a recurring job.