Respaldar Postgres como CSV en GitHub
Este es unDevOps, Multimodal AIflujo de automatización del dominio deautomatización que contiene 17 nodos.Utiliza principalmente nodos como If, Code, Github, Postgres, ItemLists. Respaldo diario de la tabla Postgres en formato CSV a GitHub
- •Personal Access Token de GitHub
- •Información de conexión de la base de datos PostgreSQL
Nodos utilizados (17)
Categoría
{
"id": "oBJaQvcNxODDoAl1",
"meta": {
"instanceId": "52254486b159b349334953c1738da94e90477c7604aa8db2062d11afc0120739",
"templateCredsSetupCompleted": true
},
"name": "backup postgres as csv to github",
"tags": [],
"nodes": [
{
"id": "20477146-5542-4701-a92f-4300c95a0c5d",
"name": "Programación Diaria",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
-1712,
-96
],
"parameters": {
"rule": {
"interval": [
{
"field": "hours",
"hoursInterval": 24
}
]
}
},
"typeVersion": 1.2
},
{
"id": "3f5ec59d-374f-421c-a333-155c06443e5d",
"name": "Listar tablas",
"type": "n8n-nodes-base.postgres",
"position": [
-544,
64
],
"parameters": {
"table": {
"__rl": true,
"mode": "name",
"value": "={{ $json.table_name }}"
},
"schema": {
"__rl": true,
"mode": "list",
"value": "public"
},
"options": {},
"operation": "select",
"returnAll": true
},
"credentials": {
"postgres": {
"id": "0bZEnNx2jwoEznOw",
"name": "pg - n8n-discord-trigger-bot"
}
},
"typeVersion": 2.6
},
{
"id": "8d8af1f2-5b28-449d-a354-a624f9e2a53c",
"name": "Iterar sobre elementos",
"type": "n8n-nodes-base.splitInBatches",
"position": [
-912,
-96
],
"parameters": {
"options": {}
},
"typeVersion": 3
},
{
"id": "680847b4-e704-4728-8ee2-44642d931d58",
"name": "Código",
"type": "n8n-nodes-base.code",
"position": [
-752,
64
],
"parameters": {
"jsCode": "return $input.all();"
},
"typeVersion": 2
},
{
"id": "0ec30d45-c281-4d65-a966-29f615eade3a",
"name": "Convertir a Archivo1",
"type": "n8n-nodes-base.convertToFile",
"position": [
-336,
64
],
"parameters": {
"options": {
"fileName": "={{ $('List tables1').item.json.table_name }}"
},
"binaryPropertyName": "=data"
},
"typeVersion": 1.1
},
{
"id": "09466877-0cdb-4011-809f-87c696ab3717",
"name": "Listar tablas1",
"type": "n8n-nodes-base.postgres",
"position": [
-1104,
-96
],
"parameters": {
"table": {
"__rl": true,
"mode": "list",
"value": "tables",
"cachedResultName": "tables"
},
"where": {
"values": [
{
"value": "public",
"column": "table_schema"
}
]
},
"schema": {
"__rl": true,
"mode": "list",
"value": "information_schema",
"cachedResultName": "information_schema"
},
"options": {},
"operation": "select"
},
"credentials": {
"postgres": {
"id": "0bZEnNx2jwoEznOw",
"name": "pg - n8n-discord-trigger-bot"
}
},
"typeVersion": 2.6
},
{
"id": "014fa66c-4acc-4698-97cc-142efaae9376",
"name": "Listar archivos del repositorio [GITHUB]",
"type": "n8n-nodes-base.github",
"position": [
-1536,
-96
],
"webhookId": "f7310d6a-1573-4848-9757-f9a75e359e73",
"parameters": {
"owner": {
"__rl": true,
"mode": "name",
"value": "user"
},
"filePath": "=",
"resource": "file",
"operation": "list",
"repository": {
"__rl": true,
"mode": "list",
"value": "github-repo",
"cachedResultUrl": "https://github.com/user/github-repo",
"cachedResultName": "github-repo"
},
"authentication": "oAuth2"
},
"credentials": {
"githubOAuth2Api": {
"id": "g3sESgnuArjRvV8F",
"name": "GitHub account"
}
},
"typeVersion": 1,
"alwaysOutputData": true
},
{
"id": "5942926d-b940-4ba4-a0c1-7209c04c0a3c",
"name": "Combinar nombres de archivos [GITHUB]",
"type": "n8n-nodes-base.itemLists",
"position": [
-1344,
-96
],
"parameters": {
"options": {},
"operation": "aggregateItems",
"fieldsToAggregate": {
"fieldToAggregate": [
{
"fieldToAggregate": "name"
}
]
}
},
"typeVersion": 2.1
},
{
"id": "00aa6a0e-b5c1-4093-8ee0-94b35bcdd934",
"name": "Nota Adhesiva2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1584,
-256
],
"parameters": {
"color": 7,
"width": 390,
"height": 547,
"content": "## Get list of current tables\nReturn a list of existing files in GitHub repository. \nSome of them are tables, \nSome are readme files"
},
"typeVersion": 1
},
{
"id": "863c59ef-6ce2-4c22-8c0e-00b9abcfdbd9",
"name": "Dividir en elementos individuales",
"type": "n8n-nodes-base.splitInBatches",
"position": [
-80,
-112
],
"parameters": {
"options": {},
"batchSize": 1
},
"typeVersion": 2
},
{
"id": "ccee7881-77c8-419e-ad99-ac3bb113ae6b",
"name": "Verificar si el archivo existe en el repositorio",
"type": "n8n-nodes-base.if",
"position": [
160,
-128
],
"parameters": {
"conditions": {
"string": [
{
"value1": "={{ $node['Combine file names [GITHUB]'].json.name }}",
"value2": "={{ $binary.data.fileName }}",
"operation": "contains"
}
]
}
},
"typeVersion": 1
},
{
"id": "f6d53dcc-1e40-43f5-b793-4d06a55ccbed",
"name": "Actualizar archivo [GITHUB]",
"type": "n8n-nodes-base.github",
"position": [
384,
-128
],
"webhookId": "fb5f5095-cf60-4421-8b83-91041cfc8929",
"parameters": {
"owner": {
"__rl": true,
"mode": "name",
"value": "user"
},
"filePath": "={{ $binary.data.fileName }}",
"resource": "file",
"operation": "edit",
"binaryData": true,
"repository": {
"__rl": true,
"mode": "list",
"value": "github-repo",
"cachedResultUrl": "https://github.com/user/github-repo",
"cachedResultName": "github-repo"
},
"commitMessage": "=backup-{{ $now.toMillis() }}",
"authentication": "oAuth2"
},
"credentials": {
"githubOAuth2Api": {
"id": "g3sESgnuArjRvV8F",
"name": "GitHub account"
}
},
"typeVersion": 1
},
{
"id": "ebcd65d3-37ac-4d47-90dc-fede45adb9c0",
"name": "Subir archivo [GITHUB]",
"type": "n8n-nodes-base.github",
"position": [
384,
80
],
"webhookId": "17b56fbd-32da-4e39-ae22-8c01a7b4bbb6",
"parameters": {
"owner": {
"__rl": true,
"mode": "name",
"value": "user"
},
"filePath": "={{ $binary.data.fileName }}",
"resource": "file",
"binaryData": true,
"repository": {
"__rl": true,
"mode": "list",
"value": "github-repo",
"cachedResultUrl": "https://github.com/user/github-repo",
"cachedResultName": "github-repo"
},
"commitMessage": "=backup-{{ $node['Set commit date'].json.commitDate }}",
"authentication": "oAuth2"
},
"credentials": {
"githubOAuth2Api": {
"id": "g3sESgnuArjRvV8F",
"name": "GitHub account"
}
},
"typeVersion": 1
},
{
"id": "6bcbeffb-b036-45f3-88a8-dd5f1ac0fa39",
"name": "Nota Adhesiva",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1168,
-256
],
"parameters": {
"color": 5,
"width": 998,
"height": 547,
"content": "## Get postgres table data\nReturn a list of existing tables and data in the postgres. \nConvert them to csv"
},
"typeVersion": 1
},
{
"id": "88cc96e5-fc5b-4d28-8e57-82c193efb19d",
"name": "Nota Adhesiva1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-144,
-256
],
"parameters": {
"color": 7,
"width": 694,
"height": 547,
"content": "## Make a list of existing files\nCreate backup if its a new table. \nUpdate backup if there is new data in the table"
},
"typeVersion": 1
},
{
"id": "4b4f32d2-2138-4d9a-8d48-6b35b387270a",
"name": "Nota Adhesiva3",
"type": "n8n-nodes-base.stickyNote",
"position": [
-848,
320
],
"parameters": {
"color": 7,
"width": 374,
"height": 195,
"content": ""
},
"typeVersion": 1
},
{
"id": "02ddc44f-7c23-4022-9978-c43876593274",
"name": "Nota Adhesiva4",
"type": "n8n-nodes-base.stickyNote",
"position": [
-144,
320
],
"parameters": {
"color": 7,
"width": 694,
"height": 259,
"content": ""
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "747a3b1e-5b2a-4f61-875c-250bd44fbf01",
"connections": {
"680847b4-e704-4728-8ee2-44642d931d58": {
"main": [
[
{
"node": "3f5ec59d-374f-421c-a333-155c06443e5d",
"type": "main",
"index": 0
}
]
]
},
"3f5ec59d-374f-421c-a333-155c06443e5d": {
"main": [
[
{
"node": "0ec30d45-c281-4d65-a966-29f615eade3a",
"type": "main",
"index": 0
}
]
]
},
"09466877-0cdb-4011-809f-87c696ab3717": {
"main": [
[
{
"node": "8d8af1f2-5b28-449d-a354-a624f9e2a53c",
"type": "main",
"index": 0
}
]
]
},
"20477146-5542-4701-a92f-4300c95a0c5d": {
"main": [
[
{
"node": "014fa66c-4acc-4698-97cc-142efaae9376",
"type": "main",
"index": 0
}
]
]
},
"8d8af1f2-5b28-449d-a354-a624f9e2a53c": {
"main": [
[
{
"node": "863c59ef-6ce2-4c22-8c0e-00b9abcfdbd9",
"type": "main",
"index": 0
}
],
[
{
"node": "680847b4-e704-4728-8ee2-44642d931d58",
"type": "main",
"index": 0
}
]
]
},
"0ec30d45-c281-4d65-a966-29f615eade3a": {
"main": [
[
{
"node": "8d8af1f2-5b28-449d-a354-a624f9e2a53c",
"type": "main",
"index": 0
}
]
]
},
"f6d53dcc-1e40-43f5-b793-4d06a55ccbed": {
"main": [
[
{
"node": "863c59ef-6ce2-4c22-8c0e-00b9abcfdbd9",
"type": "main",
"index": 0
}
]
]
},
"ebcd65d3-37ac-4d47-90dc-fede45adb9c0": {
"main": [
[
{
"node": "863c59ef-6ce2-4c22-8c0e-00b9abcfdbd9",
"type": "main",
"index": 0
}
]
]
},
"863c59ef-6ce2-4c22-8c0e-00b9abcfdbd9": {
"main": [
[
{
"node": "ccee7881-77c8-419e-ad99-ac3bb113ae6b",
"type": "main",
"index": 0
}
]
]
},
"5942926d-b940-4ba4-a0c1-7209c04c0a3c": {
"main": [
[
{
"node": "09466877-0cdb-4011-809f-87c696ab3717",
"type": "main",
"index": 0
}
]
]
},
"ccee7881-77c8-419e-ad99-ac3bb113ae6b": {
"main": [
[
{
"node": "f6d53dcc-1e40-43f5-b793-4d06a55ccbed",
"type": "main",
"index": 0
}
],
[
{
"node": "ebcd65d3-37ac-4d47-90dc-fede45adb9c0",
"type": "main",
"index": 0
}
]
]
},
"014fa66c-4acc-4698-97cc-142efaae9376": {
"main": [
[
{
"node": "5942926d-b940-4ba4-a0c1-7209c04c0a3c",
"type": "main",
"index": 0
}
]
]
}
}
}¿Cómo usar este flujo de trabajo?
Copie el código de configuración JSON de arriba, cree un nuevo flujo de trabajo en su instancia de n8n y seleccione "Importar desde JSON", pegue la configuración y luego modifique la configuración de credenciales según sea necesario.
¿En qué escenarios es adecuado este flujo de trabajo?
Avanzado - DevOps, IA Multimodal
¿Es de pago?
Este flujo de trabajo es completamente gratuito, puede importarlo y usarlo directamente. Sin embargo, tenga en cuenta que los servicios de terceros utilizados en el flujo de trabajo (como la API de OpenAI) pueden requerir un pago por su cuenta.
Flujos de trabajo relacionados recomendados
Jay Emp0
@jay-emp0AI and Automation developer. Im implementing n8n and ai tools to automate marketing and sales in companies
Compartir este flujo de trabajo