Sync Salesforce files to AWS S3 backups
This is a 'Workflow' template which means that it is a single standalone workflow.
Some workflow templates can be modified to work with other workflow templates - e.g. to convert a data sync between two services from uni-directional to bi-directional
OverviewCopy
This workflow uses a scheduled trigger, which fires the workflow daily and copies any new or updated files from Salesforce, and stores them in AWS S3.
Connectors UsedCopy
The following connectors are used in this template. This is provided for reference only - although you may need to consult the Salesforce and S3 docs for authentication instructions:
End ResultCopy
The image below shows a synced file in S3 and Salesforce :
PrerequisitesCopy
This workflow assumes the following:
You have API credentials set up with Salesforce and AWS S3.
Getting LiveCopy
In order to configure this workflow for use:
Workflow LogicCopy
The overall logic of the workflow is:
The workflow is triggered by a scheduled trigger that runs daily.
Based on the Last Run Date, the workflow gets the file versions from Salesforce.
Loops through the received file versions, downloads the Salesforce files and uploads it to the S3 bucket.
In the end, it sets the Last Run Date, which will be used as a reference for the next run.
Implementation notesCopy
'Last Run Date' and 'Remove 7 Days'Copy
The output from the Remove 7 Days step will only be used the first time this workflow runs.
On the first run, there will be no last run date in data storage, so we need to set a date in recent history to make the first check.
The Remove 7 Days step uses the Date time helpers Minus from date operation. It takes the workflow's execution start time ($.env.execution_start_time) and removes seven days from it.
If you wish to change how far back the first check goes, you can highlight the Remove 7 Days step, and in the properties panel to the right, change the number of 'Days' based on your requirements.
After the first run, the workflow will keep track of its previous run in the Set Last Run Date step and use this value every time the workflow runs henceforth.
Get File VersionsCopy
This step using Salesforce Find records operation gets the Content Version of the files.
The output for this step includes a list of files and their details that have been newly created or updated since the last run.
To ensure this, Salesforce uses a condition to check where the LastModifiedDate
should be Greater than the Last Run Date ($.steps.storage-1.value
).
These files are later one by one downloaded from Salesforce and uploaded to S3.