On a schedule
Back up a daily export to OneDrive and email the result
Every night an export is saved to a dated OneDrive folder, old copies are cleared out, and you get an email saying it worked.
- Runs
- On a schedule
- Apps
- OneDrive, Outlook
- AI
- Not needed
- Access
- Files.ReadWrite, Mail.Send
Send this to your assistant
Create a ClickRuntime automation: every night at 2am, download our data export, save it to a dated folder in OneDrive, delete backups older than 30 days, and email me a short report from Outlook.
First time? Adding ClickRuntime to your assistant takes about two minutes.
Why use it
Why teams use this automation
Many small businesses rely on a single online tool for orders, bookings or customer records, and trust that the provider keeps it safe. If an account is deleted by mistake or a sync goes wrong, there's no copy of their own to go back to.
A nightly export saved to OneDrive gives you that copy, the clean-up keeps storage under control, and the morning email tells you it ran, so you don't find out the backups stopped months ago when you need one.
What you get out of it
A copy you control
Your data sits in your own OneDrive, separate from the tool it came from. You can restore from it whatever happens to that account.
Storage stays tidy
Copies older than your chosen number of days are deleted. Your OneDrive doesn't fill up with years of backups.
You know it worked
A short email each morning confirms the file size and folder. A missing email is a sign to check.
Nothing to remember
It runs every night without anyone downloading anything by hand.
How it works
What happens, step by step
Every night at 2am it downloads your export.
The file is saved into a folder named with today's date in OneDrive.
Backup folders older than the number of days you set are deleted, but only after today's copy is saved.
You get an email from Outlook with the file size and where it was saved.
Before it runs live
- Connect OneDrive
- Connect Outlook
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 Slack
- Combine it with other OneDrive and Outlook steps into one automation
Under the hood
The code that runs this automation
GRAPH = "https://graph.microsoft.com/v1.0"
from datetime import date, timedelta
from clickruntime import on_trigger, credentials, http
EXPORT_URL = "https://app.example.com/export/latest.zip"
ROOT = "Backups"
KEEP_DAYS = 30
ME = "me@example.com"
@on_trigger
def run(event):
data = http.get(EXPORT_URL, headers={"Authorization": f"Bearer {credentials.secret('EXPORT_TOKEN')}"}, timeout=60).content
h = {"Authorization": f"Bearer {credentials.connection('microsoft', 'work')}"}
today = date.today().isoformat()
http.put(f"{GRAPH}/me/drive/root:/{ROOT}/{today}/export.zip:/content", headers=h, data=data).raise_for_status()
cutoff = (date.today() - timedelta(days=KEEP_DAYS)).isoformat()
removed = 0
for f in http.get(f"{GRAPH}/me/drive/root:/{ROOT}:/children", headers=h).json()["value"]:
if f.get("folder") and f["name"] < cutoff:
http.delete(f"{GRAPH}/me/drive/items/{f['id']}", headers=h)
removed += 1
text = f"Saved {len(data) / 1e6:.1f} MB to {ROOT}/{today}. Removed {removed} old backup(s)."
http.post(f"{GRAPH}/me/sendMail", headers=h, json={"message": {"subject": "Backup complete",
"body": {"contentType": "Text", "content": text}, "toRecipients": [{"emailAddress": {"address": ME}}]}})
return {"size": len(data), "removed": removed}FAQ
Common questions
What can it back up?
How long are backups kept?
What happens if the export fails?
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
Save a monthly KPI report to OneDrive and email the link
On the 1st of each month a report with last month's numbers and a short commentary is saved to OneDrive and the link is emailed to your team.
See how it worksLog feedback in Excel on OneDrive and get an email
Each feedback submission becomes a row in your Excel workbook and you get an email with what was said.
See how it worksSave email attachments to OneDrive folders
Attachments from incoming emails are filed in OneDrive by sender, with a log of every file saved.
See how it worksKeep exploring
Set up “Back up a daily export to OneDrive and email the result” from your assistant
Copy the prompt above, or connect your assistant first. Free plan, no credit card.