Skip to content

Instantly share code, notes, and snippets.

@m-hesse
Last active March 10, 2025 20:11
Show Gist options
  • Select an option

  • Save m-hesse/901658805129be15da66d3dc54c92ef3 to your computer and use it in GitHub Desktop.

Select an option

Save m-hesse/901658805129be15da66d3dc54c92ef3 to your computer and use it in GitHub Desktop.
N8n - Save workflows and credentials
{
"nodes": [
{
"parameters": {},
"name": "On clicking 'execute'",
"type": "n8n-nodes-base.manualTrigger",
"position": [
20,
480
],
"typeVersion": 1,
"id": "10a3a95c-2c58-4474-9d31-067581144bd8"
},
{
"parameters": {
"triggerTimes": {
"item": [
{
"hour": 1
},
{
"hour": 13
}
]
}
},
"name": "Cron1",
"type": "n8n-nodes-base.cron",
"position": [
20,
340
],
"typeVersion": 1,
"id": "c00cf87b-2f67-4829-923c-2c701527e8ed"
},
{
"parameters": {
"command": "# Backup erstellen\nBACKUP_DATE=$(date +\"%Y-%m-%d_%H-%M-%S\")\nmkdir -p /backup/credentials/$BACKUP_DATE\nnpx n8n export:credentials --backup --output /backup/credentials/$BACKUP_DATE/\n\n# Überprüfen, ob das Backup Verzeichnis JSON-Dateien enthält\nif ls /backup/credentials/$BACKUP_DATE/*.json 1> /dev/null 2>&1; then\n # Löschen aller *.json-Dateien in /backup/credentials/\n find /backup/credentials/ -maxdepth 1 -type f -name \"*.json\" -exec rm {} +\n\n # Kopieren der *.json-Dateien ins Zielverzeichnis\n cp /backup/credentials/$BACKUP_DATE/*.json /backup/credentials/\nelse\n echo \"Keine JSON-Dateien im Verzeichnis $BACKUP_DATE gefunden.\"\nfi\n"
},
"name": "Export Credentials",
"type": "n8n-nodes-base.executeCommand",
"position": [
460,
340
],
"typeVersion": 1,
"id": "2eac18b0-28ab-443f-b9a7-264297b6cfb9"
},
{
"parameters": {
"command": "# Backup erstellen\nBACKUP_DATE=$(date +\"%Y-%m-%d_%H-%M-%S\")\nmkdir -p /backup/workflows/$BACKUP_DATE\nnpx n8n export:workflow --backup --output /backup/workflows/$BACKUP_DATE/\n\n# Überprüfen, ob das Backup Verzeichnis JSON-Dateien enthält\nif ls /backup/workflows/$BACKUP_DATE/*.json 1> /dev/null 2>&1; then\n # Löschen aller *.json-Dateien in /backup/workflows/\n find /backup/workflows/ -maxdepth 1 -type f -name \"*.json\" -exec rm {} +\n\n # Kopieren der *.json-Dateien ins Zielverzeichnis\n cp /backup/workflows/$BACKUP_DATE/*.json /backup/workflows/\nelse\n echo \"Keine JSON-Dateien im Verzeichnis $BACKUP_DATE gefunden.\"\nfi\n"
},
"name": "Export Workflows",
"type": "n8n-nodes-base.executeCommand",
"position": [
280,
340
],
"typeVersion": 1,
"id": "8207ffcf-b49d-43e6-9913-b5d5bfa2ba38"
}
],
"connections": {
"On clicking 'execute'": {
"main": [
[
{
"node": "Export Workflows",
"type": "main",
"index": 0
}
]
]
},
"Cron1": {
"main": [
[
{
"node": "Export Workflows",
"type": "main",
"index": 0
}
]
]
},
"Export Credentials": {
"main": [
[]
]
},
"Export Workflows": {
"main": [
[
{
"node": "Export Credentials",
"type": "main",
"index": 0
}
]
]
}
},
"pinData": {
"On clicking 'execute'": [
{}
]
},
"meta": {
"instanceId": "5fab609e97caf85a95cad132b5c4a20271d41f64fb86f9c1bf9200f21d684f36"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment