API version: 0.3.0

---

# `backup:convert`

Converts a backup with legacy UUIDv4 element ids into a new backup with UUIDsv2a7 element ids, see
[element ids](/reference/elements/element-id.md). It also replaces `CREATED` relations by the `createdBy` property, see
below.

The `source` argument is required and must match an existing backup. The source backup is never modified; all data is
copied into a new backup, which has to be a name which is not used yet.

Options:

- `-t`, `--target` - name of the new backup, defaults to `<source>-converted`.
- `-f`, `--force` - also converts backups which were created with version 0.2.0 or newer. Without it, such backups are
  refused, as they already use the new format.
- `--mapping-output` - path of the CSV file which receives the mapping of old to new ids. By default, it is written to
  `uuid-mapping.csv` within the new backup. The file uses `;` as delimiter, has the header `UUIDv4;UUIDsv2a7` and is
  sorted by the old id.

The random part of every new id is derived deterministically from the legacy id. The timestamp is taken from the
`created` property of the element; elements without it share the time of the conversion. Ids in the `id`, `start`, and
`end` properties of nodes and relations are converted, ids within other properties are not. Files are renamed to the new
id. Folders which are derived from ids, as created by `backup:create`, are recalculated; all other folders are kept. Ids
which are already in the new format are kept.

Which backups are converted is decided by the `version` property of the backup's `summary.json`, which `backup:create`
writes. Backups of versions before 0.2.0 are converted; later versions, including pre-releases of 0.2.0, are refused
unless `--force` is used. Backups of development builds (`dev`) and backups without a version cannot be classified and
are converted with a warning.

Older versions stored the creator of an element as a `CREATED` relation from the user to the element. These relations
are removed; the id of the user is written into the `createdBy` property of the created element instead. If an element
has several `CREATED` relations, the first one is used and a warning is shown. `summary.json` is updated as well: the
element counts and the graph structure (`graphStructure.nodeTypes` and `graphStructure.relationTypes`) are written
from the converted elements.

## Help

```bash
php bin/console backup:convert --help
```

```text
Description:
  Converts a backup with legacy UUIDv4 element ids into a new backup with UUIDsv2a7 element ids.

Usage:
  backup:convert [options] [--] <source>

Arguments:
  source                               Name of the existing backup

Options:
  -t, --target=TARGET                  Name of the new backup, defaults to '<source>-converted'
  -f, --force                          Also convert backups which were created with version 0.2.0 or newer
      --mapping-output=MAPPING-OUTPUT  Path of the CSV file which receives the id mapping, defaults to 'uuid-mapping.csv' within the new backup
  -h, --help                           Display help for the given command. When no command is given display help for the list command
      --silent                         Do not output any message
  -q, --quiet                          Only errors are displayed. All other output is suppressed
  -V, --version                        Display this application version
      --ansi|--no-ansi                 Force (or disable --no-ansi) ANSI output
  -n, --no-interaction                 Do not ask any interactive question
  -e, --env=ENV                        The Environment name. [default: "prod"]
      --no-debug                       Switch off debug mode.
      --profile                        Enables profiling (requires debug).
  -v|vv|vvv, --verbose                 Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
```

## Example

```bash
php bin/console backup:convert reference-dataset --target reference-dataset-converted
```

```text
    ▄
  ▄▀ ▀▄  Ember Nexus API
   ▀█▀   v0.3.0, production mode

  Backup Convert

           
 [WARNING] The backup was created with the non-release version 'dev', it is
           assumed to be created before 0.2.0.
           

┌ Step 1 of 4: Converting Nodes ────────────────────────────────────────────────
└ Converted 1342 nodes.

┌ Step 2 of 4: Converting Relations ────────────────────────────────────────────
└ Converted 3065 relations, replaced 0 CREATED relations by createdBy properties.

┌ Step 3 of 4: Copying Files ───────────────────────────────────────────────────
└ Copied 69 files.

┌ Step 4 of 4: Copying Remaining Files ─────────────────────────────────────────
└ Copied 9 other files.

▶ Converted 0 legacy element ids. New backup 'reference-dataset-converted' was created, source backup 'reference-dataset' is unchanged.
```

---

Home: [Ember Nexus API docs](/index.md)

Full site map: [llms.txt](/llms.txt)

Next: [backup:create](/command/backup-create.md)
