Export Content using the CLI | Old Commands
Wenn Sie Ihre Inhalte von einem Stapel auf einen anderen migrieren möchten, müssen Sie den Inhalt aus dem Quellstapel exportieren und ihn dann in den Zielstapel importieren.
Sie können die folgenden Module aus einem Stack exportieren:
- Vermögenswerte
- Locales
- Umgebungen
- Extensions
- Webhooks
- Globale Felder
- Content Types
- Einträge
- Labels
- Arbeitsablauf
Voraussetzungen
- Contentstack -Konto
- CLI installiert
- Ein konfiguriertes Verwaltungstoken (Alias) oder Authentifizierungstoken
Befehle
The cm:export command lets you export content from one stack to another.
Below we have listed down how you can use the cm:export command:
- Exportieren Sie Inhalte mit Verwaltungstoken und Parametern
- Exportieren Sie Inhalte mithilfe des Management-Tokens und der Konfigurationsdatei
- Exportieren Sie Inhalte mithilfe von Authentifizierungstoken und Parametern
- Exportieren Sie Inhalte mit Auth-Token und Konfigurationsdatei
Lassen Sie uns im Detail verstehen, wie Sie Inhalte aus Ihrem Stack exportieren können.
Exportieren Sie Inhalte mit Verwaltungstoken und Parametern
Mit diesem Befehl können Sie Inhalte mithilfe eines Verwaltungstokens exportieren. Der Einfachheit halber können Sie diesem Befehl mehrere Parameter/Optionen gleichzeitig übergeben.
Tipp: To store the exported content efficiently, create a folder named “content” in your system and make a note of its path
Usage
csdx cm:export -a <management_token_alias>
Alternativ können Sie den folgenden Befehl verwenden, um mehrere Parameter/Optionen in einer einzigen Zeile hinzuzufügen:
csdx cm:export -a <management_token_alias> -d <file_path>
Optionen
- -a, --management-token-alias=management-token-alias: The management token of the source stack from which you will export content
- -d, --data=data: The path or the location in your file system to store the exported content. For e.g., ./content
- -B, --branch=branch: The name of the branch where you want to export your content. If you don’t mention the branch name, then by default the content will be exported from all the branches of your stack.
- -m, --module=module: (optional) Specify a module to export to the source stack. If not specified, the export command will export all the modules to the stack. The available modules are assets, content-types, entries, environments, extensions, global-fields, labels, locales, webhooks, and workflows.
Beispiele:
- So exportieren Sie alle Module aus einem Stack:
csdx cm:export -a mytoken -d "C:\Users\Name\Desktop\cli\content"
- To export all modules from a particular branch of your stack(For example: entwickeln).
csdx cm:export -a mytoken -d "C:\Users\Name\Desktop\cli\content" -B develop
- So exportieren Sie nur Inhaltstypen aus einem Stapel:ODER
csdx cm:export -a mytoken -d "C:\Users\Name\Desktop\cli\content" -m content-types
csdx cm:export -a mytoken -d "C:\Users\Name\Desktop\cli\content" --module content-types
- So exportieren Sie nur Umgebungen aus einem Stapel:ODER
csdx cm:export -a mytoken -d "C:\Users\Name\Desktop\cli\content" -m environments
csdx cm:export -a mytoken -d "C:\Users\Name\Desktop\cli\content" --module environments
Note: When exporting modules individually, make sure you follow this module sequence: assets > environments > locales > extensions > webhooks > global-fields > content-types > workflows > entries > labels. For example, before exporting entries, you must have had exported assets, environments, locales, extensions, webhooks, global-fields, content-types, and workflows.
Exportieren Sie Inhalte mithilfe des Management-Tokens und der Konfigurationsdatei
This command lets you export content to your stack using a management token and a configuration file containing the parameters/options and their associated value.
Um mit diesem Befehl zu beginnen, laden Sie diese Konfigurationsdatei herunter, fügen Sie Werte zu dieser Datei hinzu und notieren Sie sich den Pfad, in dem Sie diese Datei gespeichert haben. Auf diese Weise müssen Sie im Befehl keine separaten Parameter/Optionen angeben.
Tipp: Um den exportierten Inhalt effizient zu speichern, erstellen Sie in Ihrem System einen Ordner mit dem Namen „content“ und notieren Sie sich dessen Pfad.
Usage
csdx cm:export -a <management_token_alias> -c <config_file_path>
Optionen
- -a, --management-token-alias=management-token-alias: The management token of the source stack from which you will export content
- -c, --config=config: The path of the configuration JSON file containing all the options for a single run. You can refer to an example config file here.
Beispiel
- So exportieren Sie Inhalte mithilfe einer Konfigurationsdatei:
csdx cm:export -a mytoken -c “C:/Users/Name/Desktop/cli/config.json”
Exportieren Sie Inhalte mithilfe von Authentifizierungstoken und Parametern
Mit dieser Methode können Sie Inhalte in Ihren Stack exportieren, wenn Sie sich mit dem Login- Befehl bei der Sitzung angemeldet haben. Durch Ausführen des Anmeldebefehls wird ein Authentifizierungstoken generiert, das im folgenden Befehl verwendet wird.
Tipp: Um die exportierten Inhalte effizient zu speichern, erstellen Sie in Ihrem System einen Ordner mit dem Namen „content“ und notieren Sie sich dessen Pfad.
Usage
csdx cm:export -A
Alternatively, refer to the below command for adding several parameters/options in a single line:
csdx cm:export -A -s <stack_ApiKey> -d <file_path>
Optionen
- -A, --auth-token: To use the auth token of the current session. It is automatically generated and stored in the session after running the login command.
- -d, --data=data: The path or the location in your file system to store the exported content. For e.g., ./content
- -s, --stack-uid=stack-uid: The API key of the source stack.
- -t, --content-type=contentType: (optional) Content type.
- -B, --branch=branch: The name of the branch where you want to export your content. If you don’t mention the branch name, then by default the content will be exported from all the branches of your stack.
- -m, --module=module (optional): Specify the module to export to the source stack. If not specified, the export command will export all the modules to the stack. The available modules are assets, content-types, entries, environments, extensions, global-fields, labels, locales, workflows, releases, webhooks, and workflows.
- --secured-assets: Use this flag to export your content, if the secured assets feature is enabled for your stack.
Hinweis: Stellen Sie sicher, dass Sie das Flag --secured-assets hinzufügen, um Fehler beim Exportieren von Inhalten für den Stack zu vermeiden, in dem die Funktion für gesicherte Assets aktiviert ist.
Beispiele
- So exportieren Sie alle Module aus einem Stack:
csdx cm:export -A -d "C:\Users\Name\Desktop\cli\content" -s bltxxxxxx
- To export all modules from a particular branch of your stack(For example: entwickeln).
csdx cm:export -A -d "C:\Users\Name\Desktop\cli\content" -s bltxxxxxx -B develop
- So exportieren Sie nur Inhaltstypen aus einem Stapel:ODER
csdx cm:export -A -d "C:\Users\Name\Desktop\cli\content" -m content-types -s bltxxxxxx
csdx cm:export -A -d "C:\Users\Name\Desktop\cli\content" --module content-types -s bltxxxxxxxx
- So exportieren Sie nur Umgebungen aus einem Stapel:ODER
csdx cm:export -A -d "C:\Users\Name\Desktop\cli\content" -m environments -s bltxxxxxx
csdx cm:export -A -d "C:\Users\Name\Desktop\cli\content" --module environments -s bltxxxxxxxx
- So exportieren Sie Inhalte aus Ihrem Stack, bei dem die Funktion „Gesicherte Assets“ aktiviert ist:
csdx cm:export -A -d "C:\Users\Name\Desktop\cli\content" -s bltxxxxxx --secured-assets
Note: When exporting modules individually, make sure you follow this module sequence: assets > locales > environments > extensions > webhooks > global-fields > content-types > workflows > entries > labels. For example, before exporting entries, you must have had exported assets, environments, locales, extensions, webhooks, global-fields, content-types, and workflows.
Exportieren Sie Inhalte mit Auth-Token und Konfigurationsdatei
This command lets you export content to your stack using an auth token and a configuration file containing the parameters/options and their associated value.
Um mit diesem Befehl zu beginnen, laden Sie diese Konfigurationsdatei herunter, fügen Sie Werte zu dieser Datei hinzu und notieren Sie sich den Pfad, in dem Sie diese Datei gespeichert haben.
Auf diese Weise müssen Sie im Befehl keine separaten Parameter/Optionen angeben.
Tipp: Um die exportierten Inhalte effizient zu speichern, erstellen Sie in Ihrem System einen Ordner mit dem Namen „content“ und notieren Sie sich dessen Pfad.
Usage
csdx cm:export -A -c <config_file_path>
Optionen
- -A, --auth-token: To use the auth token of the current session. It is automatically generated and stored in the session after running the login command.
- -c, --config=config: The path of the configuration JSON file containing all the options for a single run. You can refer to an example config file.
Beispiel
- So exportieren Sie Inhalte mithilfe einer Konfigurationsdatei:
csdx cm:export -A -c “C:/Users/Name/Desktop/cli/config.json”
Einschränkungen
- Wenn Sie bei Assets zwei oder mehr Assets mit derselben UID und demselben Dateinamen exportieren, wird nur das erste Asset in der Warteschlange exportiert.
- Derzeit können Sie keine Inhalte aus den folgenden Modulen exportieren: