Skip to content

On a schedule

Back up your data to Drive every night

Each night your data is saved to a dated Drive folder, and backups older than 30 days go to trash.

Runs
On a schedule
Apps
Google Drive
AI
Not needed
Access
read+write (drive.file is enough if ClickRuntime created the folders)

Send this to your assistant

Create a ClickRuntime automation: every night at 2am, export all records from this API as JSON into a new dated folder in my Backups Drive folder, and move backups older than 30 days to trash.

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 founder runs a customer portal on a hosted service that exports data through an API: users, orders, support tickets. The service keeps its own backups, but they live in the same account and cannot be restored on demand. The only copy she controls is the one someone remembers to download by hand. If the account is suspended or a bad import overwrites records, she has nothing to go back to, and old exports pile up in Drive when they are made.

Every night, ClickRuntime calls the source API and fetches the export, creates a Drive folder named with the date, and uploads each JSON file into it. After the upload it lists the dated folders and moves those older than 30 days to the trash, so the archive keeps a rolling month without growing forever.

It works for any tool with an export endpoint, including CRMs, billing platforms and helpdesks.

What you get out of it

  • A copy you hold yourself

    Provider backups sit behind the provider's login and rules. A dated copy in your own Drive means you can still reach your customer and order records if an account is locked or a vendor has an outage.

  • Recover from bad imports and deletes

    A mistaken bulk update can overwrite thousands of rows before anyone spots it. With a folder for each night, you can look back to the last good day and see exactly what the data looked like.

  • Storage use stays predictable

    Deleting backups older than 30 days stops the archive from growing indefinitely. You keep a month of history at a roughly constant size, instead of finding a year of exports in a quota alert.

  • Easy to hand to an auditor

    Dated folders with identical file names make it simple to show an auditor or a buyer's due diligence team that your data is exported regularly and that retention is managed deliberately.

  • No weekly download chore

    A manual export depends on whoever remembers it, and it is the first task dropped in a busy week. A scheduled run takes that dependency away, and the nightly pattern is the same during holidays.

How it works

What happens, step by step

  1. Every night ClickRuntime downloads a full export of your app's records.

  2. It saves the export as a file in a new Google Drive folder named with today's date.

  3. Backup folders older than 30 days are moved to the trash, so Drive doesn't fill up.

  4. You end up with a rolling month of dated backups in your Backups folder.

Before it runs live

  • Connect Google Drive

What you get

RunsOn a schedule
Back up your data to Drive every nighttoday, 9:00Succeeded
Google Drive · Backups2026-10-19/records.json saved (4,812 records) Moved 2026-09-18 to trash

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 Google Drive 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_of_an_app_s_data_to_drive_with_clean_up.pyexample
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
import json
from datetime import datetime, timedelta, timezone
from googleapiclient.http import MediaInMemoryUpload
from clickruntime import on_trigger, credentials, http

BACKUPS_FOLDER = "your-backups-folder-id"
API_URL = "https://api.example.com/v1/records"

@on_trigger
def run(event):
    drive = build("drive", "v3", credentials=Credentials(credentials.connection("google", "work")), cache_discovery=False)
    records = http.get(API_URL, headers={"Authorization": f"Bearer {credentials.secret('APP_API_KEY')}"}).json()
    today = datetime.now(timezone.utc).strftime("%Y-%m-%d")
    folder = drive.files().create(body={"name": today, "mimeType": "application/vnd.google-apps.folder",
                                        "parents": [BACKUPS_FOLDER]}, fields="id").execute()
    drive.files().create(body={"name": "records.json", "parents": [folder["id"]]},
                         media_body=MediaInMemoryUpload(json.dumps(records).encode(), "application/json")).execute()
    cutoff = (datetime.now(timezone.utc) - timedelta(days=30)).isoformat()
    old = drive.files().list(q=f"'{BACKUPS_FOLDER}' in parents and createdTime < '{cutoff}' and trashed = false",
                             fields="files(id,name)").execute()["files"]
    for f in old:
        drive.files().update(fileId=f["id"], body={"trashed": True}).execute()
    return {"saved": len(records), "trashed": [f["name"] for f in old]}

FAQ

Common questions

Are deleted backups gone for good?
They are moved to Drive's trash, which holds items for about 30 days before they are removed permanently, so a mistake can still be undone for a while. You choose the retention age, and folders are only removed if their name matches the dated pattern.
Can it back up more than one source?
Yes. You can add several exports in the same run, each saved in its own subfolder inside the dated folder, or run separate schedules for each system. Keep each source's API key stored as its own secret so rotating one does not affect the others.
Is the backup encrypted?
The files are stored in your Google Drive, which encrypts data at rest and in transit. If the export contains sensitive personal data, keep the folder private and restrict sharing, and tell your AI assistant if you want extra protection before upload.
What permissions does it need?
read+write (drive.file is enough if ClickRuntime created the folders). 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 your data to Drive every night” from your assistant

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