Skip to content

Instantly share code, notes, and snippets.

@unlocomqx
Last active December 6, 2025 20:03
Show Gist options
  • Select an option

  • Save unlocomqx/b1974bd65409e2b41dcac5c01643854f to your computer and use it in GitHub Desktop.

Select an option

Save unlocomqx/b1974bd65409e2b41dcac5c01643854f to your computer and use it in GitHub Desktop.
{
"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": {
"id": "LOXXFPR0lS2UMOAa",
"name": "n8n account"
}
}
},
{
"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": {
"id": "j4kfIJC4HMvVFtA8",
"name": "Google Drive account"
}
}
},
{
"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": {
"id": "j4kfIJC4HMvVFtA8",
"name": "Google Drive account"
}
}
},
{
"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": {
"id": "j4kfIJC4HMvVFtA8",
"name": "Google Drive account"
}
}
},
{
"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": {
"id": "j4kfIJC4HMvVFtA8",
"name": "Google Drive account"
}
}
},
{
"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": {
"id": "j4kfIJC4HMvVFtA8",
"name": "Google Drive account"
}
}
},
{
"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
}
]
]
}
},
"pinData": {},
"meta": {
"templateCredsSetupCompleted": true,
"instanceId": "b925dde278e559e0d490e7389b69917163007b0eac664f344b0338b1a374b734"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment