-
Notifications
You must be signed in to change notification settings - Fork 2
/
backup-n8n-workflows-JRwxtCOVW11UUIWD.json
1 lines (1 loc) · 9.64 KB
/
backup-n8n-workflows-JRwxtCOVW11UUIWD.json
1
{"createdAt":"2023-09-16T21:41:10.343Z","updatedAt":"2023-10-01T22:39:18.145Z","id":"JRwxtCOVW11UUIWD","name":"Backup n8n Workflows","active":true,"nodes":[{"parameters":{"options":{}},"id":"c053dd1f-504e-4489-be5e-c2c456cd618c","name":"Set date","type":"n8n-nodes-base.dateTime","typeVersion":2,"position":[1499.2528427493457,1029.8065175238871]},{"parameters":{"operation":"formatDate","date":"={{ $json.currentDate }}","format":"custom","customFormat":"dd-MM-yyyy/H:mm","options":{}},"id":"c03890bb-e2e5-41d2-bb3a-0a43d9b774f3","name":"Format date","type":"n8n-nodes-base.dateTime","typeVersion":2,"position":[1699.2528427493457,1029.8065175238871]},{"parameters":{"keepOnlySet":true,"values":{"string":[{"name":"commitDate","value":"={{ $json.formattedDate }}"}]},"options":{}},"id":"cb7e3450-3121-4cb2-9ef1-48da2a73b827","name":"Set commit date","type":"n8n-nodes-base.set","typeVersion":2,"position":[1899.2528427493457,1029.8065175238871]},{"parameters":{"resource":"file","operation":"list","owner":{"__rl":true,"value":"barnyp","mode":"list","cachedResultName":"barnyp","cachedResultUrl":"https://github.com/barnyp"},"repository":{"__rl":true,"value":"n8n-workflows","mode":"list","cachedResultName":"n8n-workflows","cachedResultUrl":"https://github.com/barnyp/n8n-workflows"}},"id":"639dc489-ecc1-476c-a5d8-dbaedcca1584","name":"List files from repository [GITHUB]","type":"n8n-nodes-base.github","typeVersion":1,"position":[2099,1029],"alwaysOutputData":true,"credentials":{"githubApi":{"id":"c5ktjnaOtocdNfm1","name":"GitHub API"}}},{"parameters":{"operation":"aggregateItems","fieldsToAggregate":{"fieldToAggregate":[{"fieldToAggregate":"name"}]},"options":{}},"id":"1d5afe73-388d-4ad6-9b99-0877bfd02329","name":"Combine file names [GITHUB]","type":"n8n-nodes-base.itemLists","typeVersion":2.1,"position":[2299,1029]},{"parameters":{"filters":{}},"id":"52bdf279-4084-41d0-be71-f73f433284b3","name":"Retrieve workflows [N8N]","type":"n8n-nodes-base.n8n","typeVersion":1,"position":[2500,1020],"credentials":{"n8nApi":{"id":"1TTftu5a1OexCZ7c","name":"n8n API"}}},{"parameters":{"mode":"jsonToBinary","options":{"fileName":"={{ $json.name.replace(/\\s+/g, '-').toLowerCase() }}-{{ $json.id }}.json"}},"id":"b7e26f32-9c0c-47c8-a0c3-d990f190c7da","name":"Move JSON to binary","type":"n8n-nodes-base.moveBinaryData","typeVersion":1,"position":[2699,1029]},{"parameters":{"batchSize":1,"options":{}},"id":"5f26d2b0-136c-4d26-a719-217e57b5ec12","name":"Split to single items","type":"n8n-nodes-base.splitInBatches","typeVersion":2,"position":[2920,1000]},{"parameters":{"conditions":{"string":[{"value1":"={{ $node['Combine file names [GITHUB]'].json.name }}","operation":"contains","value2":"={{ $binary.data.fileName }}"}]}},"id":"a9456f83-cfa8-49ef-a511-736d32116f9b","name":"Check if file exists in repository","type":"n8n-nodes-base.if","typeVersion":1,"position":[3180,940]},{"parameters":{"resource":"file","operation":"edit","owner":{"__rl":true,"value":"barnyp","mode":"list","cachedResultName":"barnyp","cachedResultUrl":"https://github.com/barnyp"},"repository":{"__rl":true,"value":"n8n-workflows","mode":"list","cachedResultName":"n8n-workflows","cachedResultUrl":"https://github.com/barnyp/n8n-workflows"},"filePath":"={{ $binary.data.fileName}}","binaryData":true,"commitMessage":"=backup- {{ $('Set commit date').item.json.commitDate }}"},"id":"2dcc1d9c-6e35-49d7-98be-f3413537b607","name":"Update file [GITHUB]","type":"n8n-nodes-base.github","typeVersion":1,"position":[3400,740],"credentials":{"githubApi":{"id":"c5ktjnaOtocdNfm1","name":"GitHub API"}}},{"parameters":{"resource":"file","owner":{"__rl":true,"value":"barnyp","mode":"list","cachedResultName":"barnyp","cachedResultUrl":"https://github.com/barnyp"},"repository":{"__rl":true,"value":"n8n-workflows","mode":"list","cachedResultName":"n8n-workflows","cachedResultUrl":"https://github.com/barnyp/n8n-workflows"},"filePath":"={{ $binary.data.fileName }}","binaryData":true,"commitMessage":"=backup-{{ $node['Set commit date'].json.commitDate }}"},"id":"cc5dcdca-4ce4-419a-bb8b-c100b3c670f3","name":"Upload file [GITHUB]","type":"n8n-nodes-base.github","typeVersion":1,"position":[3420,960],"credentials":{"githubApi":{"id":"c5ktjnaOtocdNfm1","name":"GitHub API"}}},{"parameters":{"content":"## Trigger\nYou can change it to [\"Schedule\" trigger](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.scheduletrigger/) to make backups on regular basis.","height":339.51767272727324,"width":182.4715262478496},"id":"93d63214-ae04-4a3f-9726-ece5b652aaf6","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[1259.2528427493457,869.8065175238871]},{"parameters":{"content":"## Set and format date/time\nThose nodes are responsible for setting a current date and time in format `dd-MM-yyyy/H:mm`. Date and time are used to compose commit messages in GitHub, for example: `backup-12-07-2023/14:18`.","height":339.42690909090965,"width":585.4045090909088},"id":"c53bf322-7ac2-480f-add3-68d7df9c1fb9","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[1456.7952427493458,869.8065175238871]},{"parameters":{"content":"## Make a list of existing files\nReturn a list of existing files (backups) in GitHub repository. Data returned by those nodes is used by \"IF\" node (later in workflow) to check whether the backup files should be created or updated.","height":339.42690909090965,"width":389.89265454545443},"id":"c833e11e-82d3-44c6-9227-0158e066538c","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[2059.2528427493457,869.8065175238871]},{"parameters":{"content":"## Retrieve workflows\nGet all workflows form your n8n instance. Remember that **your credentials need to point to the instance that you want to backup.**","height":339.42690909090965,"width":384.14708363636373},"id":"72fcfbf9-7f1e-454c-8f7e-0e6a8b8d61e2","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[2464.168042749345,869.8065175238871]},{"parameters":{"content":"## Upload backup\nSplit JSON files into batches of 1, check if they were uploaded to repository before. If yes (true), upload the new version of the file. Otherwise (false) create the file in repository.","height":773.6601698796185,"width":703.8733020263451},"id":"74ee66bd-a117-4182-953c-b7baf999d7b9","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[2860,620]},{"parameters":{"content":"## ⚠️ Note\n\n1. Complete video guide for this workflow is available [on my YouTube](https://www.youtube.com/watch?v=dNuVuoPD0Jo). \n2. Remember to add your credentials and configure GitHub nodes (covered in the video guide).\n3. If you like this workflow, please subscribe to [my YouTube channel](https://www.youtube.com/@workfloows) and/or [my newsletter](https://workfloows.com/).\n\n**Thank you for your support!**","height":234.82946582693546,"width":508.8662091091177},"id":"3b9beb86-0800-4449-9091-da3c44cac79f","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[1260,620]},{"parameters":{"events":["init"]},"id":"8634c92f-4811-49a0-9c04-113a2ce90151","name":"n8n Trigger","type":"n8n-nodes-base.n8nTrigger","typeVersion":1,"position":[1280,1020]},{"parameters":{"conditions":{"string":[{"value1":"={{ $binary.data.fileName }}","operation":"notContains","value2":"={{ $node['Combine file names [GITHUB]'].json.name }}"}]}},"id":"25a65da8-6c9a-4144-8f52-4a343b4a1d09","name":"Check if file does not exists in repository","type":"n8n-nodes-base.if","typeVersion":1,"position":[3180,1160]},{"parameters":{"resource":"file","operation":"delete","owner":{"__rl":true,"value":"barnyp","mode":"list","cachedResultName":"barnyp","cachedResultUrl":"https://github.com/barnyp"},"repository":{"__rl":true,"value":"n8n-workflows","mode":"list","cachedResultName":"n8n-workflows","cachedResultUrl":"https://github.com/barnyp/n8n-workflows"},"filePath":"={{ $binary.data.fileName }}","commitMessage":"=deleted file -{{ $node['Set commit date'].json.commitDate }}"},"id":"894a5484-b121-49c8-9667-11a62df7cf37","name":"Delete file [GITHUB]","type":"n8n-nodes-base.github","typeVersion":1,"position":[3420,1200],"credentials":{"githubApi":{"id":"c5ktjnaOtocdNfm1","name":"GitHub API"}}}],"connections":{"Set date":{"main":[[{"node":"Format date","type":"main","index":0}]]},"Format date":{"main":[[{"node":"Set commit date","type":"main","index":0}]]},"Set commit date":{"main":[[{"node":"List files from repository [GITHUB]","type":"main","index":0}]]},"List files from repository [GITHUB]":{"main":[[{"node":"Combine file names [GITHUB]","type":"main","index":0}]]},"Combine file names [GITHUB]":{"main":[[{"node":"Retrieve workflows [N8N]","type":"main","index":0}]]},"Retrieve workflows [N8N]":{"main":[[{"node":"Move JSON to binary","type":"main","index":0}]]},"Move JSON to binary":{"main":[[{"node":"Split to single items","type":"main","index":0}]]},"Split to single items":{"main":[[{"node":"Check if file exists in repository","type":"main","index":0}]]},"Check if file exists in repository":{"main":[[{"node":"Update file [GITHUB]","type":"main","index":0}],[{"node":"Upload file [GITHUB]","type":"main","index":0}]]},"Update file [GITHUB]":{"main":[[{"node":"Split to single items","type":"main","index":0}]]},"Upload file [GITHUB]":{"main":[[{"node":"Split to single items","type":"main","index":0}]]},"n8n Trigger":{"main":[[{"node":"Set date","type":"main","index":0}]]},"Check if file does not exists in repository":{"main":[[{"node":"Delete file [GITHUB]","type":"main","index":0}]]},"Delete file [GITHUB]":{"main":[[{"node":"Split to single items","type":"main","index":0}]]}},"settings":{"executionOrder":"v1"},"staticData":null,"meta":null,"pinData":{},"versionId":"d0e8b231-149f-43b3-8906-ebd9dac481ec","triggerCount":1,"tags":[]}