AutomationFlowsData & Sheets › Webhook-Triggered Postgres Backup via SSH

Webhook-Triggered Postgres Backup via SSH

Original n8n title: Ru Backup

ru-backup. Uses postgres, ssh. Webhook trigger; 5 nodes.

Webhook trigger★★★★☆ complexity5 nodesPostgresSsh
Data & Sheets Trigger: Webhook Nodes: 5 Complexity: ★★★★☆ Added:

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "active": false,
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "IF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "Postgres",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "SSH",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "createdAt": "2023-03-09T07:28:04.397Z",
  "dataLoaded": true,
  "id": 39,
  "name": "ru-backup",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "0afda7c0-c0d2-4c3d-853e-7cf5dc5ce4db",
        "options": {}
      },
      "id": "65e48c43-6cca-428b-a3a2-6e663d31ab05",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        620,
        360
      ]
    },
    {
      "parameters": {
        "jsCode": "// Loop over input items and add a new field\n// called 'myNewField' to the JSON of each one\nconst body = $input.first().json[\"body\"];\nconst connection_string = `postgresql://${body.user}:${body.password}@${body.host}:${body.port}/${body.database}`;\n\nreturn [{connection_string, name: body.database}];"
      },
      "id": "78466d14-469f-4bc9-9e71-11fa11ba2942",
      "name": "Code",
      "type": "n8n-nodes-base.code",
      "typeVersion": 1,
      "position": [
        1040,
        180
      ]
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "=insert into databases (name, connection_string, pg_version, test_ok) values ('{{  $json[\"name\"] }}', pgp_sym_encrypt('{{ $json[\"connection_string\"]  }}', 'my_secret_key'), 14, true) ",
        "additionalFields": {}
      },
      "id": "fe490b3d-6689-4693-acbc-132ebb03fe99",
      "name": "Postgres",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 1,
      "position": [
        1320,
        180
      ],
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "boolean": [
            {
              "value1": "={{ $json[\"body\"][\"insert\"] }}",
              "value2": true
            }
          ]
        }
      },
      "id": "cc7eddf3-a933-46d0-9143-daa71dc9a065",
      "name": "IF",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        860,
        360
      ]
    },
    {
      "parameters": {
        "authentication": "privateKey",
        "command": "=sudo -u root pgdelete.sh {{ $json[\"body\"][\"database\"] }}",
        "cwd": "/backup"
      },
      "id": "c6e510f6-28eb-4272-9aeb-954b14cb254f",
      "name": "SSH",
      "type": "n8n-nodes-base.ssh",
      "typeVersion": 1,
      "position": [
        1060,
        500
      ],
      "credentials": {
        "sshPrivateKey": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "settings": {},
  "staticData": null,
  "tags": [],
  "updatedAt": "2024-10-23T22:41:25.104Z",
  "versionId": "34b950d2-5e12-4e09-bf85-e5aebff659bc"
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

ru-backup. Uses postgres, ssh. Webhook trigger; 5 nodes.

Source: https://github.com/kazitcin/n8n/blob/0847fdc65aef59776cfcb7815566d0fc485695d9/workflows/ru-backup.json — original creator credit. Request a take-down →

More Data & Sheets workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

Data & Sheets

Scraping. Uses httpRequest, postgres, @apify/n8n-nodes-apify, respondToWebhook. Webhook trigger; 61 nodes.

HTTP Request, Postgres, @Apify/N8N Nodes Apify
Data & Sheets

Workflow B — AI Listing Engine. Uses httpRequest, postgres, errorTrigger. Webhook trigger; 47 nodes.

HTTP Request, Postgres, Error Trigger
Data & Sheets

How it works

Postgres, Email Send
Data & Sheets

This workflow automates data maturity evaluation to measure how well an organization uses data to create value by capturing assessment data through forms or APIs, processing and scoring responses usin

Email Send, Postgres
Data & Sheets

Orders. Uses postgres. Webhook trigger; 26 nodes.

Postgres