Skip to content

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.

Paste it into your assistant. It tells you what it will send or change before it runs live.

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

  1. Every night at 2am it downloads your export.

  2. The file is saved into a folder named with today's date in OneDrive.

  3. Backup folders older than the number of days you set are deleted, but only after today's copy is saved.

  4. 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

RunsOn a schedule
Back up a daily export to OneDrive and email the resulttoday, 9:00Succeeded
Email · Backup completeSaved 48.2 MB to Backups/2026-10-19. Removed 1 old backup(s).

Build your own

Need it to work differently?

This template is a starting point. Copy the prompt and change it, or describe a different automation from scratch, with your own conditions, more apps or an AI step. Your assistant writes it, tests it and runs it on ClickRuntime.
  • 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

This is the Python script that runs each time the automation starts. Your AI assistant writes it for you when you send the prompt, and you allow each step in your assistant. To change how the automation works, describe the change to your assistant and it updates the script for you. For every function it can use, see the script reference.
backups_to_onedrive_with_an_email_report.pyexample
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?
Anything you can download from a web address, such as an export link, a database dump endpoint or a report URL.
How long are backups kept?
As many days as you choose. Thirty days is a common choice.
What happens if the export fails?
You get an email saying it failed and why, and older backups are not deleted that night.
What permissions does it need?
Files.ReadWrite, Mail.Send. Nothing else in your accounts is used.
Does it need AI?
No. It runs without AI, so it doesn't use your plan's AI allowance.
How many runs does it use?
One run each time it runs (on a schedule). Checks that find nothing to do and stop right away aren't counted.
Can I change how it works?
Yes. Describe the change to your AI assistant, for example a different schedule, channel or filter. It updates the automation, tests it and tells you what changed.

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.