backup-airtable


Namebackup-airtable JSON
Version 0.1.0 PyPI version JSON
download
home_pageNone
SummaryQuickly and painlessly dump all your Airtable schemas & data to JSON.
upload_time2024-04-26 01:30:22
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseNone
keywords airtable backup exporter
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # backup-airtable

Export your [Airtable](https://airtable.com/) data to JSON files. It exports both the table's schema and the records.

## Installation

The easiest way to run this is using [pipx](https://pypa.github.io/pipx/):

```shell
pipx install backup-airtable
```

<!-- You can also use brew:

```shell
brew install ...
``` -->

## Usage

Once [authenticated](#authentication), running `backup-airtable` will immediately start downloading data. There are a few available options (viewable via `backup-airtable --help`):

```
Usage: backup-airtable [OPTIONS] [BACKUP_DIRECTORY]

  Save data from Airtable to a series of local JSON files / folders

Options:
  --version              Show the version and exit.
  --ignore_table TEXT    Table id(s) to ignore when backing up.
  --airtable-token TEXT  Airtable Access Token  [required]
  --help                 Show this message and exit.
```

You'll likely only need `ignore_table` (which you can specify multiple times) to ignore specific tables from bases you otherwise want to include.

### Examples

- `backup-airtable`
- `backup-airtable some_backup_folder`
- `backup_airtable --ignore_table tbl123 --ignore_table tbl456`

## Authentication

You need to create a [personal access token](https://airtable.com/developers/web/guides/personal-access-tokens) to use this tool. It has the format `pat123.456`. They can be created at https://airtable.com/create/tokens.

Ensure it has the following scopes:

- `data.records:read`
- `schema.bases:read`

You can give it access to as many or as few bases as you'd like. Everything the token has access to will be backed up.

### Supplying the Key

You can make the key available in the environment as `AIRTABLE_TOKEN` or via the `--airtable-token` flag:

- `AIRTABLE_TOKEN=pat123.456 backup-airtable`
- `backup-airtable --airtable-token pat123.456`

## Exported Data Format

This tool creates folders for each base, each containing `records.json` and `schema.json`:

```
. (backup_directory)
├── videogames/
│   ├── games/
│   │   ├── schema.json
│   │   └── records.json
│   └── playthroughs/
│       ├── schema.json
│       └── records.json
└── tv/
    ├── shows/
    │   ├── schema.json
    │   └── records.json
    ├── seasons/
    │   ├── schema.json
    │   └── records.json
    └── watches/
        ├── schema.json
        └── records.json
```

The contents of each file is the raw API response for [the table's schema](https://airtable.com/developers/web/api/get-base-schema) (which includes formula definitions):

```json
{
  "fields": [
    {
      "id": "fldAReWzcSCy8lR6S",
      "name": "Name",
      "type": "singleLineText"
    },
    {
      "id": "fldapjPtWVGLeVEz6",
      "name": "Style",
      "options": {
        "choices": [
          {
            "color": "redLight2",
            "id": "selpGtES7bVHWFO68",
            "name": "Competitive"
          },
          {
            "color": "blueLight2",
            "id": "sel176WltZzGmNl3l",
            "name": "Cooperative"
          }
        ]
      },
      "type": "singleSelect"
    }
  ],
  "id": "tblvcNVpUk07pRxUQ",
  "name": "Games",
  "primaryFieldId": "fldAReWzcSCy8lR6S",
  "views": [
    {
      "id": "viw2PrDfjQquMoTKb",
      "name": "Main View",
      "type": "grid"
    },
    {
      "id": "viweVcA0peE3M3zag",
      "name": "Add a New Game",
      "type": "form"
    }
  ]
}
```

and the [records themselves](https://airtable.com/developers/web/api/list-records):

```json
[
  {
    "createdTime": "2017-09-19T06:21:48.000Z",
    "fields": {
      "Name": "Libertalia: Winds of Galecrest",
      "Style": "Competitive"
    },
    "id": "rec0wIiSnMutUfoTY"
  },
  {
    "createdTime": "2023-09-19T06:20:20.000Z",
    "fields": {
      "Name": "Hanabi",
      "Style": "Cooperative"
    },
    "id": "rec48RFqGw8hAmZFY"
  }
]
```

## Differences from Upstream

This was forked from [simonw/airtable-export](https://github.com/simonw/airtable-export) and adapted for my own needs. In the interest of simplicity, I:

- made `backup_directory` optional; it defaults to `./airtable-backup-<ISO_DATE>`
- removed `ndjson`, `yaml`, and `sqlite` options; it always outputs formatted JSON
- removed `base_id`; it pulls every base the auth token has access to
- removed `user-agent` option for simplicity (though would be open to re-adding it later, if needed). It makes calls as default of `backup-airtable`
- removed `schema` option; it always dumps the schema
- removed `http-read-timeout`; it defaults to a high-enough value of 60 seconds
- it doesn't flatten the record. the top level keys are `id`, `createdTime`, and `fields`

## Development

This project uses [just](https://github.com/casey/just) for running tasks. First, create a virtualenv:

```shell
python -m venv .venv
source .venv/bin/activate
```

Then run `just install` to install the project and its development dependencies. At that point, the `backup-airtable` will be available. Run `just` to see all the available commands.


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "backup-airtable",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "airtable, backup, exporter",
    "author": null,
    "author_email": "David Brownman <beamneocube@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/d0/6c/aa08a7c48413b83780175b4602ab9cb27d329719bb0a4cd591031e0cd7f1/backup_airtable-0.1.0.tar.gz",
    "platform": null,
    "description": "# backup-airtable\n\nExport your [Airtable](https://airtable.com/) data to JSON files. It exports both the table's schema and the records.\n\n## Installation\n\nThe easiest way to run this is using [pipx](https://pypa.github.io/pipx/):\n\n```shell\npipx install backup-airtable\n```\n\n<!-- You can also use brew:\n\n```shell\nbrew install ...\n``` -->\n\n## Usage\n\nOnce [authenticated](#authentication), running `backup-airtable` will immediately start downloading data. There are a few available options (viewable via `backup-airtable --help`):\n\n```\nUsage: backup-airtable [OPTIONS] [BACKUP_DIRECTORY]\n\n  Save data from Airtable to a series of local JSON files / folders\n\nOptions:\n  --version              Show the version and exit.\n  --ignore_table TEXT    Table id(s) to ignore when backing up.\n  --airtable-token TEXT  Airtable Access Token  [required]\n  --help                 Show this message and exit.\n```\n\nYou'll likely only need `ignore_table` (which you can specify multiple times) to ignore specific tables from bases you otherwise want to include.\n\n### Examples\n\n- `backup-airtable`\n- `backup-airtable some_backup_folder`\n- `backup_airtable --ignore_table tbl123 --ignore_table tbl456`\n\n## Authentication\n\nYou need to create a [personal access token](https://airtable.com/developers/web/guides/personal-access-tokens) to use this tool. It has the format `pat123.456`. They can be created at https://airtable.com/create/tokens.\n\nEnsure it has the following scopes:\n\n- `data.records:read`\n- `schema.bases:read`\n\nYou can give it access to as many or as few bases as you'd like. Everything the token has access to will be backed up.\n\n### Supplying the Key\n\nYou can make the key available in the environment as `AIRTABLE_TOKEN` or via the `--airtable-token` flag:\n\n- `AIRTABLE_TOKEN=pat123.456 backup-airtable`\n- `backup-airtable --airtable-token pat123.456`\n\n## Exported Data Format\n\nThis tool creates folders for each base, each containing `records.json` and `schema.json`:\n\n```\n. (backup_directory)\n\u251c\u2500\u2500 videogames/\n\u2502   \u251c\u2500\u2500 games/\n\u2502   \u2502   \u251c\u2500\u2500 schema.json\n\u2502   \u2502   \u2514\u2500\u2500 records.json\n\u2502   \u2514\u2500\u2500 playthroughs/\n\u2502       \u251c\u2500\u2500 schema.json\n\u2502       \u2514\u2500\u2500 records.json\n\u2514\u2500\u2500 tv/\n    \u251c\u2500\u2500 shows/\n    \u2502   \u251c\u2500\u2500 schema.json\n    \u2502   \u2514\u2500\u2500 records.json\n    \u251c\u2500\u2500 seasons/\n    \u2502   \u251c\u2500\u2500 schema.json\n    \u2502   \u2514\u2500\u2500 records.json\n    \u2514\u2500\u2500 watches/\n        \u251c\u2500\u2500 schema.json\n        \u2514\u2500\u2500 records.json\n```\n\nThe contents of each file is the raw API response for [the table's schema](https://airtable.com/developers/web/api/get-base-schema) (which includes formula definitions):\n\n```json\n{\n  \"fields\": [\n    {\n      \"id\": \"fldAReWzcSCy8lR6S\",\n      \"name\": \"Name\",\n      \"type\": \"singleLineText\"\n    },\n    {\n      \"id\": \"fldapjPtWVGLeVEz6\",\n      \"name\": \"Style\",\n      \"options\": {\n        \"choices\": [\n          {\n            \"color\": \"redLight2\",\n            \"id\": \"selpGtES7bVHWFO68\",\n            \"name\": \"Competitive\"\n          },\n          {\n            \"color\": \"blueLight2\",\n            \"id\": \"sel176WltZzGmNl3l\",\n            \"name\": \"Cooperative\"\n          }\n        ]\n      },\n      \"type\": \"singleSelect\"\n    }\n  ],\n  \"id\": \"tblvcNVpUk07pRxUQ\",\n  \"name\": \"Games\",\n  \"primaryFieldId\": \"fldAReWzcSCy8lR6S\",\n  \"views\": [\n    {\n      \"id\": \"viw2PrDfjQquMoTKb\",\n      \"name\": \"Main View\",\n      \"type\": \"grid\"\n    },\n    {\n      \"id\": \"viweVcA0peE3M3zag\",\n      \"name\": \"Add a New Game\",\n      \"type\": \"form\"\n    }\n  ]\n}\n```\n\nand the [records themselves](https://airtable.com/developers/web/api/list-records):\n\n```json\n[\n  {\n    \"createdTime\": \"2017-09-19T06:21:48.000Z\",\n    \"fields\": {\n      \"Name\": \"Libertalia: Winds of Galecrest\",\n      \"Style\": \"Competitive\"\n    },\n    \"id\": \"rec0wIiSnMutUfoTY\"\n  },\n  {\n    \"createdTime\": \"2023-09-19T06:20:20.000Z\",\n    \"fields\": {\n      \"Name\": \"Hanabi\",\n      \"Style\": \"Cooperative\"\n    },\n    \"id\": \"rec48RFqGw8hAmZFY\"\n  }\n]\n```\n\n## Differences from Upstream\n\nThis was forked from [simonw/airtable-export](https://github.com/simonw/airtable-export) and adapted for my own needs. In the interest of simplicity, I:\n\n- made `backup_directory` optional; it defaults to `./airtable-backup-<ISO_DATE>`\n- removed `ndjson`, `yaml`, and `sqlite` options; it always outputs formatted JSON\n- removed `base_id`; it pulls every base the auth token has access to\n- removed `user-agent` option for simplicity (though would be open to re-adding it later, if needed). It makes calls as default of `backup-airtable`\n- removed `schema` option; it always dumps the schema\n- removed `http-read-timeout`; it defaults to a high-enough value of 60 seconds\n- it doesn't flatten the record. the top level keys are `id`, `createdTime`, and `fields`\n\n## Development\n\nThis project uses [just](https://github.com/casey/just) for running tasks. First, create a virtualenv:\n\n```shell\npython -m venv .venv\nsource .venv/bin/activate\n```\n\nThen run `just install` to install the project and its development dependencies. At that point, the `backup-airtable` will be available. Run `just` to see all the available commands.\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Quickly and painlessly dump all your Airtable schemas & data to JSON.",
    "version": "0.1.0",
    "project_urls": {
        "Author": "https://xavd.id",
        "Bug Tracker": "https://github.com/xavdid/backup-airtable/issues",
        "Changelog": "https://github.com/xavdid/backup-airtable/blob/main/CHANGELOG.md",
        "Homepage": "https://github.com/xavdid/backup-airtable"
    },
    "split_keywords": [
        "airtable",
        " backup",
        " exporter"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4abe711f5cba9bb7d345627230f36a3d0c02469c104130df73341ae4746016a8",
                "md5": "d2f0ea679ad300396989046be71ce173",
                "sha256": "b7190fb4a804c656e49c77e29c39d249eea564c462ce213a10c3200ff41b2de9"
            },
            "downloads": -1,
            "filename": "backup_airtable-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d2f0ea679ad300396989046be71ce173",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 9895,
            "upload_time": "2024-04-26T01:30:21",
            "upload_time_iso_8601": "2024-04-26T01:30:21.309138Z",
            "url": "https://files.pythonhosted.org/packages/4a/be/711f5cba9bb7d345627230f36a3d0c02469c104130df73341ae4746016a8/backup_airtable-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d06caa08a7c48413b83780175b4602ab9cb27d329719bb0a4cd591031e0cd7f1",
                "md5": "e2dbf7c6c5fabd09b57d790789a79d64",
                "sha256": "a0aff4c86cae86c96b971840190f15b65559e564d5efc0585afa54f991a515ad"
            },
            "downloads": -1,
            "filename": "backup_airtable-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "e2dbf7c6c5fabd09b57d790789a79d64",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 9010,
            "upload_time": "2024-04-26T01:30:22",
            "upload_time_iso_8601": "2024-04-26T01:30:22.699858Z",
            "url": "https://files.pythonhosted.org/packages/d0/6c/aa08a7c48413b83780175b4602ab9cb27d329719bb0a4cd591031e0cd7f1/backup_airtable-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-26 01:30:22",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "xavdid",
    "github_project": "backup-airtable",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "backup-airtable"
}
        
Elapsed time: 0.23310s