On a schedule
Move old Salesforce files to S3 and report in Slack
Every week, Salesforce files older than a year are moved to your S3 bucket to free up storage, and Slack reports how many files and megabytes were archived.
- Runs
- On a schedule
- Apps
- AWS, Slack
- AI
- Not needed
- Access
- s3:PutObject; chat:write
Send this to your assistant
Create a ClickRuntime automation: every Sunday, move Salesforce files older than a year into S3, delete them from Salesforce once copied, and post how many files and MB were archived to #ops.
First time? Adding ClickRuntime to your assistant takes about two minutes.
Why use it
Why teams use this automation
Salesforce file storage is expensive, and years of attachments, signed contracts and old proposals fill it up. Buying more storage costs far more than keeping the same files in S3, but moving them by hand is a project nobody wants.
A weekly job that moves anything older than a year keeps Salesforce under its storage limit while the files stay available in your own bucket.
What you get out of it
Lower storage costs
S3 storage costs a fraction of extra Salesforce file storage.
Stay under your limit
A steady weekly clear-out avoids hitting the storage cap at a bad moment.
Nothing is lost
Each file is copied and checked in S3 before it's removed from Salesforce.
A visible record
The Slack report shows how much was moved each week.
How it works
What happens, step by step
Every Sunday, ClickRuntime asks Salesforce for files last changed more than a year ago.
It downloads each one and saves it to your S3 bucket.
Once a file is safely in S3, it's deleted from Salesforce.
It posts the number of files and megabytes archived to #ops in Slack.
Before it runs live
- Connect AWS
- Connect Slack, then invite the app to the channel (type /invite @ClickRuntime there)
What you get
Build your own
Need it to work differently?
Your own rules
Conditions, thresholds, filters and exceptions, written the way you'd explain them to a colleague.
Any number of apps
One automation can read from one app and update several others. Over 248 apps are ready, and anything with an API works too.
AI where it helps
Summaries, classification, extraction and drafts use ClickRuntime's built-in AI, with no extra key.
On a schedule or on each event
Runs as often as every 5 minutes, or the moment an app sends an event, and keeps track of what it already handled.
Changes you can ask for
- Run it at a different time, more or less often, or only on weekdays
- Add an AI step, for example to summarize, sort or draft a reply
- Add another app, for example also send it to Google Sheets
- Combine it with other AWS and Slack steps into one automation
Under the hood
The code that runs this automation
import boto3
from clickruntime import on_trigger, credentials, http, notify
SF = "https://northwind.my.salesforce.com/services/data/v61.0"
REGION, BUCKET = "us-east-1", "northwind-files"
def aws(service):
return boto3.client(service, region_name=REGION, aws_access_key_id=credentials.secret("AWS_ACCESS_KEY_ID"),
aws_secret_access_key=credentials.secret("AWS_SECRET_ACCESS_KEY"))
@on_trigger
def run(event):
sf = {"Authorization": "Bearer " + credentials.connection("salesforce", "work")}
q = "SELECT Id, ContentDocumentId, Title, FileExtension, ContentSize FROM ContentVersion WHERE IsLatest = true AND LastModifiedDate < LAST_N_DAYS:365 LIMIT 200"
files = http.get(f"{SF}/query", headers=sf, params={"q": q}).json()["records"]
s3, moved, size = aws("s3"), 0, 0
for f in files:
data = http.get(f"{SF}/sobjects/ContentVersion/{f['Id']}/VersionData", headers=sf, timeout=60).content
s3.put_object(Bucket=BUCKET, Key=f"salesforce-archive/{f['ContentDocumentId']}-{f['Title']}.{f['FileExtension']}", Body=data)
http.delete(f"{SF}/sobjects/ContentDocument/{f['ContentDocumentId']}", headers=sf).raise_for_status()
moved, size = moved + 1, size + f["ContentSize"]
notify.slack(f"Archived {moved} Salesforce files ({size / 1e6:,.1f} MB) to s3://{BUCKET}/salesforce-archive/", channel="#ops")
return {"files": moved, "mb": round(size / 1e6, 1)}FAQ
Common questions
Can people still find archived files?
Is anything deleted before it's safely copied?
Can I exclude certain files?
What permissions does it need?
Does it need AI?
How many runs does it use?
Can I change how it works?
Related
You might also like
Back up your Airtable base to S3 every night
Every night each table in your Airtable base is saved as a CSV in a dated S3 folder, backups older than 30 days are removed, and Slack confirms it worked.
See how it worksSave a copy of any web page to S3 and share the link in Slack
Send a URL to your automation's link and a copy of the page is saved to S3, with a download link posted to your research channel.
See how it worksPost a summary of each invoice uploaded to S3 to Slack
Each new invoice in your S3 bucket is read, and Slack gets the vendor, amount and due date within 15 minutes.
See how it worksKeep exploring
Set up “Move old Salesforce files to S3 and report in Slack” from your assistant
Copy the prompt above, or connect your assistant first. Free plan, no credit card.