Every sysadmin knows the feeling: you're about to push a risky update to your VPS and you think "I should snapshot this first" — then forget. With OpenClaw's built-in cron scheduler and your hosting provider's REST API, you can have your AI agent take a snapshot automatically on a schedule, or whenever you ask it to in chat. This guide walks through the setup using Hostinger VPS, with equivalent examples for DigitalOcean, Hetzner, and Vultr.
This tutorial works with any VPS provider that exposes a REST API for snapshots. The pattern is identical — only the endpoint URL and authentication token change.
What You'll Build
- An OpenClaw agent that can take a VPS snapshot on demand when you message it
- A scheduled cron job that snapshots your server automatically (e.g., weekly)
- A confirmation message sent to your Telegram or Slack when the snapshot completes
- A safety check that warns you if a snapshot already exists before overwriting it
Step 1 — Get Your Hostinger API Token
Hostinger uses Bearer token authentication for all API calls. To generate yours:
- Log in to hpanel.hostinger.com
- Go to Account Settings → API
- Click Generate New Token and give it a name like "OpenClaw Snapshots"
- Copy the token immediately — it's only shown once
- Note your VPS numeric ID from the VPS dashboard URL or via the API
Hostinger allows only ONE snapshot per VPS at a time. Creating a new snapshot overwrites the existing one. Your agent should warn you about this before proceeding.
Step 2 — Understand the Hostinger Snapshot API
The Hostinger VPS API exposes four simple endpoints for snapshot management. All calls use Bearer token authentication:
# Get current snapshot (check if one exists)
GET https://api.hostinger.com/api/vps/v1/virtual-machines/{vmId}/snapshot
Authorization: Bearer YOUR_API_TOKEN
# Create a new snapshot (overwrites any existing one!)
POST https://api.hostinger.com/api/vps/v1/virtual-machines/{vmId}/snapshot
Authorization: Bearer YOUR_API_TOKEN
# Restore from the current snapshot
POST https://api.hostinger.com/api/vps/v1/virtual-machines/{vmId}/snapshot/restore
Authorization: Bearer YOUR_API_TOKEN
# Delete the current snapshot
DELETE https://api.hostinger.com/api/vps/v1/virtual-machines/{vmId}/snapshot
Authorization: Bearer YOUR_API_TOKENAll requests are async — the API returns an action object immediately, and the snapshot is created in the background. Your agent can poll for completion or simply confirm the action was queued.
Step 3 — Configure Your OpenClaw Agent
Give your OpenClaw agent a system prompt that explains how to interact with your VPS. Store your credentials as environment variables and reference them in the prompt:
You are a server management assistant for [Your Name]'s VPS infrastructure.
Your VPS details:
- Provider: Hostinger
- VM ID: 123456
- API Base: https://api.hostinger.com/api/vps/v1/virtual-machines/123456
- Auth: Bearer token stored in env var HOSTINGER_API_TOKEN
You can perform the following actions when asked:
1. TAKE SNAPSHOT: POST .../snapshot
- ALWAYS check if a snapshot already exists first (GET .../snapshot)
- WARN the user that creating a snapshot will overwrite the existing one
- Only proceed after user confirms
- Report the snapshot creation time when done
2. CHECK SNAPSHOT: GET .../snapshot
- Report the snapshot date, size, and status
3. RESTORE SNAPSHOT: POST .../snapshot/restore
- This is DESTRUCTIVE — always ask for explicit confirmation
- Warn that the VPS will revert to the snapshot state and recent changes will be lost
4. DELETE SNAPSHOT: DELETE .../snapshot
- Confirm before deleting
Always use proper Authorization headers and handle API errors gracefully.Step 4 — Test On-Demand Snapshots via Chat
With the agent configured, you can now trigger snapshots by simply messaging your bot. The agent handles the API call, checks for existing snapshots, and confirms the result:
// This is what your OpenClaw agent executes internally
// when you send: "Take a snapshot of my VPS"
const token = process.env.HOSTINGER_API_TOKEN;
const vmId = '123456';
const base = `https://api.hostinger.com/api/vps/v1/virtual-machines/${vmId}`;
// Step 1: Check if snapshot already exists
const check = await fetch(`${base}/snapshot`, {
headers: { Authorization: `Bearer ${token}` }
});
const existing = await check.json();
if (existing?.created_at) {
// Warn user and wait for confirmation
return `⚠️ A snapshot from ${existing.created_at} already exists.
Proceeding will OVERWRITE it. Reply 'confirm' to continue.`;
}
// Step 2: Create snapshot after confirmation
const snap = await fetch(`${base}/snapshot`, {
method: 'POST',
headers: { Authorization: `Bearer ${token}` }
});
const action = await snap.json();
return `✅ Snapshot queued (action ID: ${action.id}).
Your VPS state is being captured — this takes 1–3 minutes.`;Step 5 — Schedule a Weekly Cron Job via Chat
OpenClaw has a built-in cron scheduler you configure entirely through conversation — no terminal or server access needed. Just tell your bot what schedule you want and it sets up the recurring job automatically:
You → Set up a weekly cron job to take a VPS snapshot every Sunday
at 3:00 AM UTC. Send me the result here on Telegram when it runs.
Don't ask for confirmation when running automatically.
Bot → ✅ Done! I've scheduled a weekly VPS snapshot job:
• Schedule: Every Sunday at 03:00 UTC
• Action: Create snapshot (auto-confirm, no prompt)
• Notification: I'll message you here after each run
You can say "show my cron jobs" or "cancel the snapshot cron"
to manage it anytime.Tell your bot exactly what you want in plain language: the schedule ("every Sunday night", "every Monday at 2am"), what to do (snapshot without confirmation for automated runs), and how to notify you (Telegram message with the result).
You can also ask your bot to list, pause, or delete cron jobs at any time just by chatting with it. OpenClaw keeps all scheduled jobs in its internal state, which persists across restarts.
Step 6 — Receive Notifications When Snapshots Complete
The --announce flag sends the agent's response to your configured channel. Your Telegram or Slack will receive a message like this after each successful snapshot:
🤖 Weekly VPS Snapshot — Completed
━━━━━━━━━━━━━━━━━━━━━━━
✅ Snapshot created successfully
📅 Date: 2026-02-26 03:02:14 UTC
💾 VM: prod-server-01 (ID: 123456)
⏱ Action ID: act_8f3k2m9x
Next snapshot: Sunday, March 3 at 03:00 UTCWorks with Any VPS Provider
The same OpenClaw pattern works with any hosting provider that exposes a REST API. Just swap the endpoint and token. Here's the equivalent for the most popular providers:
| Provider | Create Snapshot Endpoint | Auth Header |
|---|---|---|
| Hostinger | POST /api/vps/v1/virtual-machines/{id}/snapshot | Bearer token |
| DigitalOcean | POST /v2/droplets/{id}/actions (type: snapshot) | Bearer token |
| Hetzner | POST /v1/servers/{id}/actions/create_image | Bearer token |
| Vultr | POST /v2/snapshots | Bearer token |
| Linode/Akamai | POST /v4/linode/instances/{id}/backups | Bearer token |
# DigitalOcean equivalent
curl -X POST \
-H "Authorization: Bearer $DO_TOKEN" \
-H "Content-Type: application/json" \
-d '{"type":"snapshot","name":"weekly-auto-snapshot"}' \
"https://api.digitalocean.com/v2/droplets/{droplet_id}/actions"
# Hetzner equivalent
curl -X POST \
-H "Authorization: Bearer $HETZNER_TOKEN" \
-H "Content-Type: application/json" \
-d '{"description":"weekly-auto-snapshot","type":"snapshot"}' \
"https://api.hetzner.cloud/v1/servers/{server_id}/actions/create_image"
# Vultr equivalent
curl -X POST \
-H "Authorization: Bearer $VULTR_KEY" \
-H "Content-Type: application/json" \
-d '{"instance_id":"YOUR_ID","description":"weekly-auto-snapshot"}' \
"https://api.vultr.com/v2/snapshots"Practical Use Cases
- "Snapshot my server" before every deployment — ask the bot, it confirms and does it
- Weekly automated snapshot every Sunday night with Telegram confirmation
- "Restore my server" for one-command disaster recovery from chat
- "How old is my snapshot?" — check if your last backup is recent enough before making changes
- Alert you if a week passes without a successful snapshot (monitor via cron + conditional message)
“The best backup is the one that actually happens. An AI agent that takes your snapshot when you ask — and automatically on schedule — means you'll never forget again.”
— ClawDock Engineering
Deploy Your Server Management Agent
Get an OpenClaw bot running in 2 minutes. Connect it to your VPS API and manage your server infrastructure from Telegram.
Deploy Free