Daily
Create a dated backup branch every night
Your main branch is copied to a dated branch each night, and only the last seven are kept.
- Runs
- Daily
- Apps
- Neon
- AI
- Not needed
- Access
- read+write
Send this to your assistant
Create a ClickRuntime automation: every night at 1am, create a Neon branch named backup-YYYY-MM-DD from main, delete backup- branches older than 7 days, and email me a one-line summary.
First time? Adding ClickRuntime to your assistant takes about two minutes.
Why use it
Why teams use this automation
Developers using Neon often rely on point-in-time restore, which has a limited window on lower plans, and may not have a separate backup at all. A destructive migration, a bad data script or a dropped table is found three days later, after the window or at least after someone has typed more changes on top. Restoring then becomes guesswork about when the data last looked right.
Every night ClickRuntime creates a branch from your default branch with the date in its name, such as backup-2026-10-18, lists existing branches, deletes backup branches older than seven days, and emails a short summary. You always have the last seven nightly snapshots, ready to query or restore from.
Teams with production data in Neon and no other backup process tend to adopt it first.
What you get out of it
A known good copy from each of the last 7 days
If a migration goes wrong on Thursday, Wednesday night's branch has the data as it was. You can query it, compare, or promote it instead of reconstructing rows. You can compare tables side by side to find what changed.
Restores are fast and cheap to inspect
Branches are copy-on-write, so a nightly one is quick to create and available instantly. You can connect to it and check a table without any restore job. That makes checking a table before a restore a matter of one connection string.
Retention is automatic
Backups older than seven days are removed by the same run, so they do not accumulate. The project does not slowly fill with dozens of dated branches nobody dares delete.
Confidence before risky changes
Knowing last night's copy exists makes a schema change less worrying. Teams ship migrations more readily when they know the previous state is one connection string away. Teams ship migrations more readily when the old state is easy to reach.
Daily confirmation that it happened
The summary email shows the new branch and what was pruned. A missing email is itself the signal that the backup did not run. If the email stops arriving, you know straight away that the backup did not run.
How it works
What happens, step by step
Every night ClickRuntime copies your main Neon branch to a new branch named with the date.
It deletes backup branches older than seven days, so only the last week is kept.
You get an email listing the backup created and any removed.
Before it runs live
- Connect Neon
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 Neon steps into one automation
Under the hood
The code that runs this automation
from datetime import date, datetime, timedelta, timezone
from clickruntime import on_trigger, credentials, http, notify
NEON = "https://console.neon.tech/api/v2"
def neon(method, path, **kwargs):
resp = http.request(method, f"{NEON}{path}", headers={"Authorization": f"Bearer {credentials.secret('NEON_API_KEY')}"}, **kwargs)
resp.raise_for_status()
return resp.json()
PROJECT_ID = "your-neon-project-id"
@on_trigger
def run(event):
branches = neon("GET", f"/projects/{PROJECT_ID}/branches")["branches"]
main = next(b for b in branches if b.get("default"))
name = f"backup-{date.today()}"
neon("POST", f"/projects/{PROJECT_ID}/branches", json={"branch": {"name": name, "parent_id": main["id"]}})
cutoff = datetime.now(timezone.utc) - timedelta(days=7)
removed = []
for b in branches:
if b["name"].startswith("backup-") and datetime.fromisoformat(b["created_at"].replace("Z", "+00:00")) < cutoff:
neon("DELETE", f"/projects/{PROJECT_ID}/branches/{b['id']}")
removed.append(b["name"])
notify.email_me(f"Neon backup: created {name}, removed {len(removed)}", ", ".join(removed) or "No old backups removed.")
return {"created": name, "removed": removed}FAQ
Common questions
Is a branch a real backup?
Can I keep more than 7 backups?
Does creating the branch affect my database?
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
Get a weekly Neon usage report
Each Monday you see compute hours and storage for every Neon project in one email.
See how it worksGet a warning before storage runs out
You get one alert when a project's storage passes the size you set, not a repeat every check.
See how it worksDelete old preview branches nightly
Preview branches past a set age are removed each night, and you get the list of what went.
See how it worksKeep exploring
Set up “Create a dated backup branch every night” from your assistant
Copy the prompt above, or connect your assistant first. Free plan, no credit card.