workflows.fit
Back to n8n workflows
n8n template$250By Le Nguyen

Salesforce to S3 file migration & cleanup

Salesforce to S3 File Migration & Cleanup Automate archiving old Salesforce files to Amazon S3, log them back in Salesforce, and free up org storage β€” all from a scheduled n8n workflow. --- πŸ”§ How It Works (High-Level...

DevelopmentCore NodesCommunicationHITLData & StorageSalesSchedule TriggerSticky Note
Open checkout
Loading interactive preview...

Template notes

Salesforce to S3 File Migration & Cleanup

Automate archiving old Salesforce files to Amazon S3, log them back in Salesforce, and free up org storage β€” all from a scheduled n8n workflow.

---

πŸ”§ How It Works (High-Level)

1. Schedule Trigger kicks off (e.g., daily). 2. Query Salesforce for ContentDocument records older than 365 days. 3. Loop Each File β†’ download binary via REST. 4. Upload to S3 with the original filename. 5. Lookup Links (ContentDocumentLink) to keep the parent record reference. 6. Filter Out Users (ignore LinkedEntityId starting with 005). 7. Create S3Filec record in Salesforce for traceability. 8. Delete Original File from Salesforce to reclaim storage. 9. Notify via Slack when the batch is done.

![Screenshot 20250723 135316.png](fileId:1840) ---

πŸš€ Set Up Steps (Time: ~45–90 mins)

1. Import n8n Workflow JSON and wire up credentials (Salesforce OAuth2, AWS S3, Slack). 2. Install Salesforce Unmanaged Package (Custom Object S3Filec, Apex controller, LWC, settings). 3. Fill S3Settingsc (bucket, region, keys, expiry) or swap to Named Credentials. 4. Test with a Sandbox Batch (e.g., small date range) and verify upload/delete. 5. Schedule & Monitor (tweak interval, Slack channel).