PostgresをCSVとしてGitHubにバックアップ
上級
これはDevOps, Multimodal AI分野の自動化ワークフローで、17個のノードを含みます。主にIf, Code, Github, Postgres, ItemListsなどのノードを使用。 毎日、PostgresテーブルをCSV形式でGitHubにバックアップ
前提条件
- •GitHub Personal Access Token
- •PostgreSQLデータベース接続情報
ワークフロープレビュー
ノード接続関係を可視化、ズームとパンをサポート
ワークフローをエクスポート
以下のJSON設定をn8nにインポートして、このワークフローを使用できます
{
"id": "oBJaQvcNxODDoAl1",
"meta": {
"instanceId": "52254486b159b349334953c1738da94e90477c7604aa8db2062d11afc0120739",
"templateCredsSetupCompleted": true
},
"name": "backup postgres as csv to github",
"tags": [],
"nodes": [
{
"id": "20477146-5542-4701-a92f-4300c95a0c5d",
"name": "Daily Schedule",
"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": "テーブル一覧",
"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": "アイテムをループ処理",
"type": "n8n-nodes-base.splitInBatches",
"position": [
-912,
-96
],
"parameters": {
"options": {}
},
"typeVersion": 3
},
{
"id": "680847b4-e704-4728-8ee2-44642d931d58",
"name": "Code",
"type": "n8n-nodes-base.code",
"position": [
-752,
64
],
"parameters": {
"jsCode": "return $input.all();"
},
"typeVersion": 2
},
{
"id": "0ec30d45-c281-4d65-a966-29f615eade3a",
"name": "Convert to File1",
"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": "List tables1",
"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": "リポジトリからファイル一覧 [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": "ファイル名を結合 [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": "Sticky Note2",
"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": "単一アイテムに分割",
"type": "n8n-nodes-base.splitInBatches",
"position": [
-80,
-112
],
"parameters": {
"options": {},
"batchSize": 1
},
"typeVersion": 2
},
{
"id": "ccee7881-77c8-419e-ad99-ac3bb113ae6b",
"name": "リポジトリ内のファイル存在確認",
"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": "ファイル更新 [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": "ファイルアップロード [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": "Sticky Note",
"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": "Sticky Note1",
"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": "Sticky Note3",
"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": "Sticky Note4",
"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
}
]
]
}
}
}よくある質問
このワークフローの使い方は?
上記のJSON設定コードをコピーし、n8nインスタンスで新しいワークフローを作成して「JSONからインポート」を選択、設定を貼り付けて認証情報を必要に応じて変更してください。
このワークフローはどんな場面に適していますか?
上級 - DevOps, マルチモーダルAI
有料ですか?
このワークフローは完全無料です。ただし、ワークフローで使用するサードパーティサービス(OpenAI APIなど)は別途料金が発生する場合があります。
関連ワークフロー
コンテンツジェネレーター v3
AI驱动ブログ自動化:使用GPT-4生成并公開SEO記事至WordPressとTwitter
If
Set
Code
+
If
Set
Code
144 ノードJay Emp0
コンテンツ作成
高度な n8n ワークフローと GitHub の同期
GitHub による スマートな変更検出を使った ワークフロー バックアップの自動化
If
N8n
Set
+
If
N8n
Set
38 ノードMaksym Brashenko
DevOps
GitHub 同期ダッシュボード - V2
コミット履歴とロールバック機能を備えた GitHub ワークフロー バージョン管理ダッシュボード
If
N8n
Set
+
If
N8n
Set
94 ノードEduard
DevOps
Google Drive、GitHub、メッセージ アラートを使用した自動作業フロー バックアップシステム
Google Drive、GitHub、そしてメッセージアラートを使用した自動化ワークフローバックアップシステム
If
N8n
Set
+
If
N8n
Set
20 ノードKhairul Muhtadin
コンテンツ作成
ツイッター自動化
Gemini AIとGoogle Sheetsを使用した自動化されたコンテンツ&プロモーションTweetスケジューラー
If
Set
Code
+
If
Set
Code
20 ノードJay Emp0
その他
Google Drive へのワークフロー備份とスマートクリーンアップ
Google Drive へのワークフロー バックアップの自動化と スマートなクリーンアップ
N8n
Set
Code
+
N8n
Set
Code
17 ノードLuca Olovrap
DevOps
ワークフロー情報
難易度
上級
ノード数17
カテゴリー2
ノードタイプ9
作成者
Jay Emp0
@jay-emp0AI and Automation developer. Im implementing n8n and ai tools to automate marketing and sales in companies
外部リンク
n8n.ioで表示 →
このワークフローを共有