Respaldo automatizado de Rsync con autenticación por contraseña y sistema de alertas

Avanzado

Este es unautomatización que contiene 21 nodos.Utiliza principalmente nodos como If, Set, ManualTrigger, ExecuteCommand, ScheduleTrigger. Respaldo automatizado con Rsync con autenticación por contraseña y sistema de alertas

Requisitos previos
  • No hay requisitos previos especiales, puede importar y usarlo directamente

Categoría

-
Vista previa del flujo de trabajo
Visualización de las conexiones entre nodos, con soporte para zoom y panorámica
Exportar flujo de trabajo
Copie la siguiente configuración JSON en n8n para importar y usar este flujo de trabajo
{
  "id": "JxrInAO8OLCjxVC5",
  "meta": {
    "instanceId": "5c7ce220523e8664f49208a8be668a8dc6fab5f747ce4de865fa1309727919f1",
    "templateCredsSetupCompleted": true
  },
  "name": "Automated Rsync Backup with Password Auth & Alert System",
  "tags": [],
  "nodes": [
    {
      "id": "5c38117c-4f04-4033-a570-cc3d55e78f17",
      "name": "Disparador Manual",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -2800,
        224
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "f4d96789-441a-4152-b4d8-6922581dfe5b",
      "name": "Parámetros del Servidor",
      "type": "n8n-nodes-base.set",
      "position": [
        -2576,
        224
      ],
      "parameters": {
        "values": {
          "string": [
            {
              "name": "source_host",
              "value": "source_host_ip"
            },
            {
              "name": "source_port",
              "value": "source_host_ssh_port"
            },
            {
              "name": "source_user",
              "value": "source_user_username"
            },
            {
              "name": "source_password",
              "value": "=source_user_password"
            },
            {
              "name": "source_folder",
              "value": "source_path_on_the_source_host"
            },
            {
              "name": "target_host",
              "value": "target_host_ip"
            },
            {
              "name": "target_port",
              "value": "target_host_ssh_port"
            },
            {
              "name": "target_user",
              "value": "target_user_username"
            },
            {
              "name": "target_password",
              "value": "=target_user_password"
            },
            {
              "name": "target_folder",
              "value": "target_path_on_the_target_host"
            },
            {
              "name": "rsync_options",
              "value": "-avz --delete"
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "2856d809-25ad-46ba-8056-84e78c7fd66c",
      "name": "Verificar Sshpass Local",
      "type": "n8n-nodes-base.executeCommand",
      "position": [
        -2352,
        224
      ],
      "parameters": {
        "command": "which sshpass"
      },
      "typeVersion": 1,
      "continueOnFail": true
    },
    {
      "id": "98869a56-7d59-4055-bbf8-d437f6d7ca12",
      "name": "¿Está Instalado Localmente?",
      "type": "n8n-nodes-base.if",
      "position": [
        -2128,
        224
      ],
      "parameters": {
        "conditions": {
          "number": [
            {
              "value1": "={{ $json.exitCode }}"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "5fdd117b-5e40-4f21-987c-7ca7fb5b2c8b",
      "name": "Instalar Sshpass Local",
      "type": "n8n-nodes-base.executeCommand",
      "position": [
        -1920,
        320
      ],
      "parameters": {
        "command": "=if command -v apt-get &> /dev/null; then\n  apt-get update && apt-get install -y sshpass rsync\nelif command -v yum &> /dev/null; then\n  yum install -y epel-release && yum install -y sshpass rsync\nelif command -v dnf &> /dev/null; then\n  dnf install -y sshpass rsync\nelif command -v apk &> /dev/null; then\n  apk add sshpass rsync\nelse\n  echo \"Unsupported package manager\"\n  exit 1\nfi"
      },
      "typeVersion": 1
    },
    {
      "id": "2e5c2163-e384-4488-9fb6-68d74ce3e932",
      "name": "Verificar Sshpass en Origen",
      "type": "n8n-nodes-base.executeCommand",
      "position": [
        -1696,
        224
      ],
      "parameters": {
        "command": "=sshpass -p '{{ $('Server Parameters').item.json.source_password }}' ssh -o StrictHostKeyChecking=no -p {{ $('Server Parameters').item.json.source_port }} {{ $('Server Parameters').item.json.source_user }}@{{ $('Server Parameters').item.json.source_host }} \"which sshpass\""
      },
      "typeVersion": 1,
      "continueOnFail": true
    },
    {
      "id": "5916c184-5925-4fb4-8c8e-accc74e4df29",
      "name": "¿Está Instalado en Origen?",
      "type": "n8n-nodes-base.if",
      "position": [
        -1472,
        224
      ],
      "parameters": {
        "conditions": {
          "number": [
            {
              "value1": "={{ $json.exitCode }}"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "b302372f-007c-4afa-89e1-a453e03064c8",
      "name": "Instalar Sshpass en Origen",
      "type": "n8n-nodes-base.executeCommand",
      "position": [
        -1248,
        320
      ],
      "parameters": {
        "command": "=sshpass -p '{{ $('Server Parameters').item.json.source_password }}' ssh -o StrictHostKeyChecking=no -p {{ $('Server Parameters').item.json.source_port }} {{ $('Server Parameters').item.json.source_user }}@{{ $('Server Parameters').item.json.source_host }} \"if command -v apt-get &> /dev/null; then echo '{{ $('Server Parameters').item.json.source_password }}' | sudo -S apt-get update && echo '{{ $('Server Parameters').item.json.source_password }}' | sudo -S apt-get install -y sshpass rsync; elif command -v yum &> /dev/null; then echo '{{ $('Server Parameters').item.json.source_password }}' | sudo -S yum install -y epel-release && echo '{{ $('Server Parameters').item.json.source_password }}' | sudo -S yum install -y sshpass rsync; elif command -v dnf &> /dev/null; then echo '{{ $('Server Parameters').item.json.source_password }}' | sudo -S dnf install -y sshpass rsync; else echo 'Unsupported package manager'; exit 1; fi\""
      },
      "typeVersion": 1
    },
    {
      "id": "93e5b9e9-5a31-404f-932c-ba050d10e5d5",
      "name": "Ejecutar Copia de Seguridad Rsync",
      "type": "n8n-nodes-base.executeCommand",
      "position": [
        -1040,
        224
      ],
      "parameters": {
        "command": "=sshpass -p '{{ $('Server Parameters').item.json.source_password }}' ssh -o StrictHostKeyChecking=no -p {{ $('Server Parameters').item.json.source_port }} {{ $('Server Parameters').item.json.source_user }}@{{ $('Server Parameters').item.json.source_host }} \"sshpass -p '{{ $('Server Parameters').item.json.target_password }}' rsync {{ $('Server Parameters').item.json.rsync_options }} -e 'ssh -o StrictHostKeyChecking=no -p {{ $('Server Parameters').item.json.target_port }}' {{ $('Server Parameters').item.json.source_folder }}/ {{ $('Server Parameters').item.json.target_user }}@{{ $('Server Parameters').item.json.target_host }}:{{ $('Server Parameters').item.json.target_folder }}/\""
      },
      "typeVersion": 1
    },
    {
      "id": "e2b2ff1a-0d35-42ba-875d-8bb0e78dae8a",
      "name": "¿Éxito?",
      "type": "n8n-nodes-base.if",
      "position": [
        -816,
        224
      ],
      "parameters": {
        "conditions": {
          "number": [
            {
              "value1": "={{ $json.exitCode }}",
              "operation": "equal"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ae9e2524-1b95-4473-8679-1b42809583cd",
      "name": "Copia de Seguridad Exitosa",
      "type": "n8n-nodes-base.set",
      "position": [
        -592,
        128
      ],
      "parameters": {
        "values": {
          "string": [
            {
              "name": "status",
              "value": "SUCCESS"
            },
            {
              "name": "timestamp",
              "value": "={{ $now.format('YYYY-MM-DD HH:mm:ss') }}"
            },
            {
              "name": "source",
              "value": "={{ $('Server Parameters').item.json.source_host }}:{{ $('Server Parameters').item.json.source_folder }}"
            },
            {
              "name": "target",
              "value": "={{ $('Server Parameters').item.json.target_host }}:{{ $('Server Parameters').item.json.target_folder }}"
            },
            {
              "name": "output",
              "value": "={{ $('Execute Rsync Backup').item.json.stdout }}"
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "3d4ee816-96aa-4ac3-ab96-54f8ab220807",
      "name": "Copia de Seguridad Fallida",
      "type": "n8n-nodes-base.set",
      "position": [
        -592,
        320
      ],
      "parameters": {
        "values": {
          "string": [
            {
              "name": "status",
              "value": "ERROR"
            },
            {
              "name": "timestamp",
              "value": "={{ $now.format('YYYY-MM-DD HH:mm:ss') }}"
            },
            {
              "name": "source",
              "value": "={{ $('Server Parameters').item.json.source_host }}"
            },
            {
              "name": "target",
              "value": "={{ $('Server Parameters').item.json.target_host }}"
            },
            {
              "name": "output",
              "value": "={{ $('Execute Rsync Backup').item.json.exitCode }} -- {{ $('Execute Rsync Backup').item.json.stderr }}"
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "f7d833ae-0003-48f8-8d13-4f22cb70f52f",
      "name": "Reporte de Finalización de Proceso --- Telegam & SMS",
      "type": "n8n-nodes-base.executeCommand",
      "onError": "continueRegularOutput",
      "position": [
        -272,
        224
      ],
      "parameters": {
        "command": "=apk add curl\n\nexport TOKEN=\"YOUR-TELEGRAM-BOT-TOKEN\"\nexport CHAT_ID=\"YOUR-TELEGRAM-CHANNEL-ID\"\nexport MESSAGE=\"{{ $json.timestamp }} -- {{ $json.status }} :: {{ $json.source }} -> {{ $json.target }} :: {{ $json.output }}\"\n\ncurl -s -X POST \"https://api.telegram.org/bot$TOKEN/sendMessage\" -d chat_id=\"$CHAT_ID\" -d text=\"$MESSAGE\"\n\nNUMBERS=\"+36301234567\"\n\nfor PHONE in $NUMBERS; do\n  curl -X POST https://textbelt.com/text --data-urlencode phone=\"$PHONE\" --data-urlencode message=\"$MESSAGE\" -d key=YOUR-TEXTBELT-API-KEY\ndone"
      },
      "typeVersion": 1
    },
    {
      "id": "4f541742-fac7-4d71-b236-c4bc65856f4a",
      "name": "Nota Adhesiva",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3088,
        -240
      ],
      "parameters": {
        "width": 380,
        "height": 232,
        "content": "## Automated Rsync Backup\n\nPassword-based SSH backup between servers using rsync.\n\nAutomatically installs dependencies, performs backup from source to target server, and sends status notifications via Telegram and SMS.\n\nSupports Ubuntu, Debian, RHEL, CentOS, and Alpine."
      },
      "typeVersion": 1
    },
    {
      "id": "b74c3604-78af-4a0c-a7df-b4bd0c1ecd71",
      "name": "Nota Adhesiva1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2576,
        384
      ],
      "parameters": {
        "width": 340,
        "height": 348,
        "content": "## SERVER CONFIGURATION REQUIRED\n\nSource Server:\n- source_host, source_port, source_user\n- source_password, source_folder\n\nTarget Server:\n- target_host, target_port, target_user\n- target_password, target_folder\n\nRsync Options:\n- Default: -avz --delete\n- Archive, verbose, compress, mirror"
      },
      "typeVersion": 1
    },
    {
      "id": "b6910e2a-f654-4918-a3e1-51bddbe9bb51",
      "name": "Nota Adhesiva2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2352,
        -64
      ],
      "parameters": {
        "width": 340,
        "height": 248,
        "content": "## Dependency Management\n\nAutomatically checks and installs sshpass and rsync:\n1. Check if sshpass installed locally\n2. Install if missing (apt/yum/dnf/apk)\n3. Check sshpass on source server\n4. Install on source if needed (with sudo)\n\nNo manual installation required."
      },
      "typeVersion": 1
    },
    {
      "id": "720d40a5-6799-4d92-8b2d-1b4e27e7408c",
      "name": "Nota Adhesiva3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1040,
        -64
      ],
      "parameters": {
        "width": 320,
        "height": 256,
        "content": "## Backup Execution\n\nConnects to source server via SSH and executes rsync command.\n\nData transfers directly between source and target servers, not through n8n.\n\nUses password authentication for both connections with StrictHostKeyChecking disabled."
      },
      "typeVersion": 1
    },
    {
      "id": "55adad40-e782-4687-bd28-d99414754a2e",
      "name": "Nota Adhesiva4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -592,
        464
      ],
      "parameters": {
        "width": 300,
        "height": 224,
        "content": "## Status Handling\n\nChecks rsync exit code:\n- Exit 0: Success - captures stdout\n- Non-zero: Failure - captures exit code and stderr\n\nBoth paths generate detailed status report with timestamp and server info."
      },
      "typeVersion": 1
    },
    {
      "id": "db8dbab3-3671-424e-b690-d82c56bed6c5",
      "name": "Nota Adhesiva5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -272,
        -96
      ],
      "parameters": {
        "width": 340,
        "height": 296,
        "content": "## NOTIFICATION CONFIGURATION\n\nReplace placeholders:\n- YOUR-TELEGRAM-BOT-TOKEN\n- YOUR-TELEGRAM-CHANNEL-ID\n- +36301234567 (phone numbers)\n- YOUR-TEXTBELT-API-KEY\n\nSends success or failure report with timestamp, source, target, and output details."
      },
      "typeVersion": 1
    },
    {
      "id": "0c19273d-a6a3-43c9-9f4a-a43f8a1029b1",
      "name": "Nota Adhesiva6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3248,
        128
      ],
      "parameters": {
        "width": 388,
        "height": 112,
        "content": "## Scheduling\n\nCurrently manual trigger and  Schedule Trigger."
      },
      "typeVersion": 1
    },
    {
      "id": "f5f0cb34-f5a9-4ad9-a2ee-54852328bc54",
      "name": "Disparador Programado",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -2800,
        32
      ],
      "parameters": {
        "rule": {
          "interval": [
            {}
          ]
        }
      },
      "typeVersion": 1.2
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "44bd3bc1-2f84-4948-b794-6a8b23b50258",
  "connections": {
    "e2b2ff1a-0d35-42ba-875d-8bb0e78dae8a": {
      "main": [
        [
          {
            "node": "ae9e2524-1b95-4473-8679-1b42809583cd",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "3d4ee816-96aa-4ac3-ab96-54f8ab220807",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "3d4ee816-96aa-4ac3-ab96-54f8ab220807": {
      "main": [
        [
          {
            "node": "f7d833ae-0003-48f8-8d13-4f22cb70f52f",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "5c38117c-4f04-4033-a570-cc3d55e78f17": {
      "main": [
        [
          {
            "node": "f4d96789-441a-4152-b4d8-6922581dfe5b",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "f5f0cb34-f5a9-4ad9-a2ee-54852328bc54": {
      "main": [
        [
          {
            "node": "f4d96789-441a-4152-b4d8-6922581dfe5b",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ae9e2524-1b95-4473-8679-1b42809583cd": {
      "main": [
        [
          {
            "node": "f7d833ae-0003-48f8-8d13-4f22cb70f52f",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "f4d96789-441a-4152-b4d8-6922581dfe5b": {
      "main": [
        [
          {
            "node": "2856d809-25ad-46ba-8056-84e78c7fd66c",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2856d809-25ad-46ba-8056-84e78c7fd66c": {
      "main": [
        [
          {
            "node": "98869a56-7d59-4055-bbf8-d437f6d7ca12",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "98869a56-7d59-4055-bbf8-d437f6d7ca12": {
      "main": [
        [
          {
            "node": "2e5c2163-e384-4488-9fb6-68d74ce3e932",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "5fdd117b-5e40-4f21-987c-7ca7fb5b2c8b",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "93e5b9e9-5a31-404f-932c-ba050d10e5d5": {
      "main": [
        [
          {
            "node": "e2b2ff1a-0d35-42ba-875d-8bb0e78dae8a",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "5fdd117b-5e40-4f21-987c-7ca7fb5b2c8b": {
      "main": [
        [
          {
            "node": "2e5c2163-e384-4488-9fb6-68d74ce3e932",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2e5c2163-e384-4488-9fb6-68d74ce3e932": {
      "main": [
        [
          {
            "node": "5916c184-5925-4fb4-8c8e-accc74e4df29",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "5916c184-5925-4fb4-8c8e-accc74e4df29": {
      "main": [
        [
          {
            "node": "93e5b9e9-5a31-404f-932c-ba050d10e5d5",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "b302372f-007c-4afa-89e1-a453e03064c8",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "b302372f-007c-4afa-89e1-a453e03064c8": {
      "main": [
        [
          {
            "node": "93e5b9e9-5a31-404f-932c-ba050d10e5d5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Preguntas frecuentes

¿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

¿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.

Información del flujo de trabajo
Nivel de dificultad
Avanzado
Número de nodos21
Categoría-
Tipos de nodos6
Descripción de la dificultad

Adecuado para usuarios avanzados, flujos de trabajo complejos con 16+ nodos

Enlaces externos
Ver en n8n.io

Compartir este flujo de trabajo

Categorías

Categorías: 34