Skip to content

Daily

Back up an export to OneDrive every night

A dated copy of your data export is saved nightly, older copies are pruned, and you hear if it fails.

Runs
Daily
Apps
OneDrive
AI
Not needed
Access
read+write (Files.ReadWrite)

Send this to your assistant

Create a ClickRuntime automation: every night at 2am, download the file from https://example.com/export.csv into OneDrive Backups named with today's date, keep 30 days of copies, and email me if it fails.

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

A small ecommerce store exports its orders, customers and product list from its platform every night, but the CSV files sit in the Downloads folder of one laptop. If that laptop dies, or the platform account is locked, the business has no recent copy. Meanwhile some people save backups to OneDrive by hand, which means two or three copies a month and a folder full of files named final_v2_REAL.csv.

Each night, the export is downloaded from the source URL and uploaded to OneDrive in a dated path, such as Backups/2026/10/orders-2026-10-19.csv. Copies older than 30 days are then deleted so the folder does not grow forever, and an email is sent only if something fails.

It suits stores, agencies and clinics with a data export that nobody wants to back up manually.

What you get out of it

  • A recent copy survives a disaster

    If a platform locks your account or a laptop is stolen, last night's export in OneDrive lets you carry on the next morning, not rebuild from memory. That is far better than discovering during an emergency that your last backup was taken three months ago.

  • Thirty days of history to roll back to

    Finding that a price list was corrupted two weeks ago is far less alarming when a copy from before the damage is a click away. That window is long enough to catch problems that are not noticed at once but still recent enough to be useful.

  • Storage stays under control

    Deleting files older than the cutoff keeps the backup folder at a predictable size, rather than eating through the plan's quota over months. It also means that an old folder of backups will not trigger a surprise storage upgrade.

  • Silence means success

    An email only on failure means that no news is good news. You are not trained to ignore a daily message that says everything is fine. A quiet inbox on normal days means the failure email gets read, which is the reason you want it.

  • Neat paths make restores simple

    Year and month folders with date-stamped names mean you can reach the right file without opening each one to check its contents. In an emergency, a clearly named file that is easy to locate saves time you do not have.

How it works

What happens, step by step

  1. Every night, ClickRuntime downloads your data export.

  2. It saves a copy to OneDrive with the date in the file name.

  3. Copies older than 30 days are deleted, so your backups do not pile up.

  4. If anything goes wrong, you get an email with the error. When the backup works, it stays quiet.

Before it runs live

  • Connect OneDrive

What you get

RunsDaily
Back up an export to OneDrive every nighttoday, 9:00Succeeded
Email · Backup failedHTTPError: 503 Server Error: Service Unavailable for url: https://app.example.com/export.csv

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 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.
scheduled_backup_into_onedrive_with_pruning.pyexample
from datetime import date, datetime, timedelta, timezone
from clickruntime import on_trigger, credentials, http, notify

GRAPH = "https://graph.microsoft.com/v1.0"
EXPORT_URL = "https://app.example.com/export.csv"
FOLDER = "Backups"
KEEP_DAYS = 30

@on_trigger
def run(event):
    try:
        h = {"Authorization": f"Bearer {credentials.connection('microsoft', 'work')}"}
        data = http.get(EXPORT_URL, headers={"Authorization": f"Bearer {credentials.secret('EXPORT_TOKEN')}"}, timeout=120).content
        http.put(f"{GRAPH}/me/drive/root:/{FOLDER}/export-{date.today()}.csv:/content", headers=h, data=data).raise_for_status()
        cutoff = (datetime.now(timezone.utc) - timedelta(days=KEEP_DAYS)).isoformat()
        old = [f for f in http.get(f"{GRAPH}/me/drive/root:/{FOLDER}:/children", headers=h).json()["value"] if f["createdDateTime"] < cutoff]
        for f in old:
            http.delete(f"{GRAPH}/me/drive/items/{f['id']}", headers=h)
        return {"bytes": len(data), "pruned": len(old)}
    except Exception as e:
        notify.email_me("Backup failed", f"{type(e).__name__}: {e}")
        raise

FAQ

Common questions

What happens if the nightly export fails?
If the download or upload fails, you receive an email stating which step broke, and the failed run is shown in the ClickRuntime dashboard. Earlier backups remain untouched, since pruning only runs after a successful upload.
Can the retention period be 90 days instead of 30?
Yes. The retention window is a number of days that you can set to whatever you want to keep, such as 14, 90 or 365. Longer retention uses more OneDrive storage. It is a single setting, and longer periods simply use more storage.
What sources can be backed up this way?
Any export reachable by URL, API or authenticated download, such as store platform exports, database dumps or reports. Credentials needed for the download are kept as secrets. Many shops back up their orders, customers, products and inventory this way.
What permissions does it need?
read+write (Files.ReadWrite). 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 (daily). 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 an export to OneDrive every night” from your assistant

Copy the prompt above, or connect your assistant first. Free plan, no credit card.