Skip to content

Daily

Back up a sheet tab every night

Each night a dated copy of your tab is kept, with the last 14 days saved.

Runs
Daily
Apps
Google Sheets
AI
Not needed
Access
read+write

Send this to your assistant

Create a ClickRuntime automation: every night, copy my Orders tab to a new tab named with today's date, keep the last 14 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

Spreadsheets get edited by many hands, and the damage is rarely noticed on the day it happens. Someone sorts only one column, an import script overwrites last month's figures, a formula range is dragged over a block of hand-typed numbers. By the time a finance lead spots that the totals look wrong, version history is a long scroll of unnamed edits and nobody can say which one was the bad one.

Each night a copy of the tab is created inside the same spreadsheet and renamed with that day's date, so you end up with a row of tabs like 2026-10-18 and 2026-10-19. Backup tabs older than 14 days are deleted to keep the file from ballooning, and if any step fails an email tells you the same morning.

It is most useful for budgets, inventory counts and customer lists that are edited constantly but only audited occasionally.

What you get out of it

  • A clean restore point every day

    If a bad paste ruins this week's data, you copy the values back from last night's tab in a minute. You are not reconstructing the sheet from scattered revision history.

  • Mistakes are found by comparing days

    With dated tabs side by side, you can see exactly when a total changed. That turns an argument about who broke it into a quick lookup with a date attached.

  • The file stays a manageable size

    Dropping copies older than 14 days stops the workbook from growing by a tab every night forever. Sheets slow down badly with hundreds of tabs, and this avoids that problem.

  • Silence means the backup worked

    You only hear about it when something fails. A broken backup you find out about months later is worse than none, so the failure email matters more than a success message would. A quiet morning inbox is the sign that the copy exists.

  • A lightweight audit trail for reviewers

    Month-end reviewers or auditors can open the tab dated the close day and see what the numbers were then, not what they have become after later edits. That is a plain, dated answer to a reviewer's question.

How it works

What happens, step by step

  1. Every night ClickRuntime makes a copy of your Orders tab inside the same Google Sheet.

  2. The copy is named with today's date.

  3. Backup tabs beyond the latest 14 are deleted, so the sheet doesn't grow forever.

  4. If the backup fails, you get an email with the reason.

Before it runs live

  • Connect your Google Sheets account and pick the spreadsheets it may use

What you get

RunsDaily
Back up a sheet tab every nighttoday, 9:00Succeeded
Email · Orders backup failedHttpError: The caller does not have permission (403)

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 Sheets 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.
nightly_sheet_backup.pyexample
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
from datetime import date
from clickruntime import on_trigger, credentials, notify

SHEET_ID = "your-spreadsheet-id"
KEEP = 14

@on_trigger
def run(event):
    try:
        sheets = build("sheets", "v4", credentials=Credentials(credentials.connection("google", "work")), cache_discovery=False).spreadsheets()
        tabs = sheets.get(spreadsheetId=SHEET_ID, fields="sheets.properties").execute()["sheets"]
        orders = next(t["properties"]["sheetId"] for t in tabs if t["properties"]["title"] == "Orders")
        requests = [{"duplicateSheet": {"sourceSheetId": orders, "newSheetName": f"Orders {date.today()}", "insertSheetIndex": len(tabs)}}]
        backups = sorted((t["properties"] for t in tabs if t["properties"]["title"].startswith("Orders 20")),
                         key=lambda p: p["title"])
        requests += [{"deleteSheet": {"sheetId": p["sheetId"]}} for p in backups[:max(0, len(backups) + 1 - KEEP)]]
        sheets.batchUpdate(spreadsheetId=SHEET_ID, body={"requests": requests}).execute()
    except Exception as e:
        notify.email_me("Orders backup failed", f"{type(e).__name__}: {e}")
        raise
    return {"copied": f"Orders {date.today()}", "removed": len(requests) - 1}

FAQ

Common questions

Where do the backup tabs go?
They are added as new tabs inside the same Google spreadsheet, named by date. That keeps everything together and shares the same permissions, though anyone with edit access to the file can also delete them. Keep a copy elsewhere if you need protection from deliberate removal.
Does it back up formulas or only values?
Duplicating a tab keeps the formulas, formatting and values as they were that night. Be aware that formulas pointing at other tabs continue to reference live data, so a restore is most reliable for the hand-entered content in the sheet.
Can I keep more than 14 days of backups?
The retention window is a number in the workflow, so asking your AI assistant to keep 30 or 60 days is a small edit. Larger spreadsheets approach Google's cell limit faster with many tabs, which is the reason a cap exists at all.
What permissions does it need?
read+write. 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 a sheet tab every night” from your assistant

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