AutomationFlowsGeneral › Self Backup

Self Backup

Self-Backup. Uses n8n, googleDrive, executeCommand. Event-driven trigger; 14 nodes.

Event trigger★★★★☆ complexity14 nodesn8nGoogle DriveExecute Command
General Trigger: Event Nodes: 14 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
{
  "nodes": [
    {
      "parameters": {},
      "id": "aa837d1f-f1ab-4d17-8709-ebf99161fc1c",
      "name": "On clicking 'execute'",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -256,
        -520
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "filters": {},
        "requestOptions": {}
      },
      "id": "dc59e3a5-9da9-4092-abbd-8d132730e4a2",
      "name": "n8n",
      "type": "n8n-nodes-base.n8n",
      "position": [
        864,
        -400
      ],
      "retryOnFail": true,
      "typeVersion": 1,
      "alwaysOutputData": true,
      "credentials": {
        "n8nApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "999b95fc-dbff-4219-affd-c08de5bd925b",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        1088,
        -400
      ],
      "typeVersion": 3
    },
    {
      "parameters": {
        "resource": "folder",
        "name": "=Workflow Backups {{ $now.format('cccc t dd-MM-yyyy') }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "folderId": {
          "__rl": true,
          "value": "1n-kAwAkiOniUDwYIo2VZomA1b6fMV_EG",
          "mode": "list",
          "cachedResultName": "n8n",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1n-kAwAkiOniUDwYIo2VZomA1b6fMV_EG"
        },
        "options": {}
      },
      "id": "c24fdee6-6ba7-42c4-b0ce-1d4d016e4dbe",
      "name": "create new folder",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        640,
        -400
      ],
      "typeVersion": 3,
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "toJson",
        "options": {
          "format": true,
          "fileName": "={{ $json.name + \".json\" }} "
        }
      },
      "id": "4f480efa-035d-441d-a857-4edae79fbb72",
      "name": "Convert to File",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        1312,
        -400
      ],
      "typeVersion": 1.1
    },
    {
      "parameters": {
        "name": "={{ $('Loop Over Items').item.json.name + \".json\" }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "folderId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('create new folder').item.json.id }}"
        },
        "options": {}
      },
      "id": "39a50f49-ad64-4236-a170-f74eb9d281df",
      "name": "Google Drive",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1536,
        -328
      ],
      "typeVersion": 3,
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours",
              "hoursInterval": 4
            }
          ]
        }
      },
      "id": "2ed58926-35aa-4219-b78b-4f8dff682279",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -256,
        -328
      ],
      "typeVersion": 1.2
    },
    {
      "parameters": {
        "resource": "folder",
        "operation": "deleteFolder",
        "folderNoRootId": {
          "__rl": true,
          "value": "={{ $json.id }}",
          "mode": "id"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        416,
        -472
      ],
      "id": "e9b8a111-6795-43ea-92d9-2534e5b348a8",
      "name": "Delete folder",
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "fileFolder",
        "searchMethod": "query",
        "queryString": "=createdTime < \"{{ new Date(new Date().getTime()-(3*30*24*60*60*1000)).toISOString()}}\"",
        "filter": {
          "folderId": {
            "__rl": true,
            "value": "1n-kAwAkiOniUDwYIo2VZomA1b6fMV_EG",
            "mode": "list",
            "cachedResultName": "n8n",
            "cachedResultUrl": "https://drive.google.com/drive/folders/1n-kAwAkiOniUDwYIo2VZomA1b6fMV_EG"
          }
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        -32,
        -400
      ],
      "id": "3919d9e1-ac50-49d6-ab36-aea10d7adf59",
      "name": "Search files and folders",
      "alwaysOutputData": true,
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.values().length }}",
                    "rightValue": 0,
                    "operator": {
                      "type": "number",
                      "operation": "gt"
                    },
                    "id": "7aa6097b-c42d-4895-bca9-f1029b75493a"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "has items"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "9ab42e1f-6e32-4dd7-a42f-36a9fb95fdad",
                    "leftValue": "={{ $json.values().length }}",
                    "rightValue": 0,
                    "operator": {
                      "type": "number",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "has no items"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.3,
      "position": [
        192,
        -400
      ],
      "id": "4cdd4b32-45e9-4755-801d-315fd1eb8a52",
      "name": "Switch"
    },
    {
      "parameters": {
        "operation": "toJson",
        "options": {
          "format": true,
          "fileName": "=cred.json"
        }
      },
      "id": "0cb9dca8-d2e0-43b7-be07-d65519da4942",
      "name": "Convert to File1",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        1760,
        -592
      ],
      "typeVersion": 1.1
    },
    {
      "parameters": {
        "name": "=creds-{{ $now.format('yyyy-MM-dd:hh:mm') }}.json",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "folderId": {
          "__rl": true,
          "value": "1n-kAwAkiOniUDwYIo2VZomA1b6fMV_EG",
          "mode": "list",
          "cachedResultName": "n8n",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1n-kAwAkiOniUDwYIo2VZomA1b6fMV_EG"
        },
        "options": {}
      },
      "id": "d58587de-af8a-4d91-8b13-25e47664119c",
      "name": "Google Drive1",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1984,
        -592
      ],
      "typeVersion": 3,
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "command": "n8n export:credentials --all 2>/dev/null"
      },
      "type": "n8n-nodes-base.executeCommand",
      "typeVersion": 1,
      "position": [
        1312,
        -592
      ],
      "id": "c52794d3-a3f4-4fd2-9c8a-0aa818aab412",
      "name": "Execute Command"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "a2ae6ce8-2882-4c8c-999a-c5b5d23d2edc",
              "name": "data",
              "value": "={{ $json.stdout }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1536,
        -592
      ],
      "id": "1cae46e7-8451-43d2-ab35-615a021b0dd8",
      "name": "Edit Fields"
    }
  ],
  "connections": {
    "On clicking 'execute'": {
      "main": [
        [
          {
            "node": "Search files and folders",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "n8n": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "Execute Command",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Convert to File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "create new folder": {
      "main": [
        [
          {
            "node": "n8n",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to File": {
      "main": [
        [
          {
            "node": "Google Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Search files and folders",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Delete folder": {
      "main": [
        [
          {
            "node": "create new folder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search files and folders": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Delete folder",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "create new folder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to File1": {
      "main": [
        [
          {
            "node": "Google Drive1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive1": {
      "main": [
        []
      ]
    },
    "Execute Command": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Convert to File1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "meta": {
    "templateCredsSetupCompleted": true
  }
}

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

Self-Backup. Uses n8n, googleDrive, executeCommand. Event-driven trigger; 14 nodes.

Source: https://gist.github.com/unlocomqx/b1974bd65409e2b41dcac5c01643854f — original creator credit. Request a take-down →

More General workflows → · Browse all categories →

Related workflows

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

General

This n8n workflow template uses community nodes and is only compatible with the self-hosted version of n8n.

n8n, Google Drive, Execute Command
General

Self-Hosted n8n Workflow Backup to Google Drive. Uses googleDrive, n8n. Event-driven trigger; 17 nodes.

Google Drive, n8n
General

🎯 Purpose: Generate audio files from text scripts stored in Google Drive.

Execute Workflow Trigger, Google Drive, Read Write File +1
General

Restoring multiple n8n workflows manually, especially when migrating your n8n instance to another host or server, can be an incredibly daunting and time-consuming task. Imagine having to individually

Google Drive, n8n
General

Using n8n a lot?

Execute Workflow Trigger, XML, Move Binary Data +1