Why PocketBase Is the Ultimate Micro-Backend for Developers
Modern web and mobile application development often gets bogged down in microservice complexity: configuring separate PostgreSQL database instances, standing up Redis caches, setting up OAuth authentication microservices, provisioning AWS S3 buckets, and managing separate REST/GraphQL API gateways. For solo developers, startups, mobile app creators, and MVPs, this operational overhead is overwhelming.
PocketBase is an open-source, all-in-one backend packaged as a single standalone Go binary. Featuring an embedded SQLite database with WAL (Write-Ahead Logging) mode, real-time WebSocket event broadcasting, built-in user authentication (with OAuth2 providers like Google, GitHub, Apple), S3/local file storage, and an elegant visual administrative dashboard, PocketBase runs comfortably on an entry-level $3/month VPS while consuming less than 15MB of idle RAM.
In this technical tutorial, we will configure PocketBase as a systemd background service on Ubuntu 24.04/22.04 LTS, secure the administrative web portal behind an Nginx reverse proxy with SSL, enable real-time WebSockets, and implement automated daily database snapshot backups.
Step 1: Downloading and Installing the PocketBase Binary
PocketBase requires no external database daemons or complex language runtimes. Download the compiled Linux binary directly:
# Create dedicated directory and download binary
sudo mkdir -p /var/www/pocketbase
cd /tmp
curl -LO https://github.com/pocketbase/pocketbase/releases/download/v0.22.14/pocketbase_0.22.14_linux_amd64.zip
# Unzip binary and place into system PATH
sudo apt update && sudo apt install -y unzip nginx certbot python3-certbot-nginx
unzip pocketbase_0.22.14_linux_amd64.zip
sudo mv pocketbase /usr/local/bin/
sudo chmod +x /usr/local/bin/pocketbase
# Verify PocketBase CLI
pocketbase --version
Step 2: Creating a Dedicated System User and Data Directory
For strict security isolation, never run web services as root:
# Create dedicated system user
sudo useradd --no-create-home --shell /bin/false pocketbase
sudo chown -R pocketbase:pocketbase /var/www/pocketbase
sudo chmod 750 /var/www/pocketbase
Step 3: Configuring Systemd Service Daemon
Create a systemd unit at /etc/systemd/system/pocketbase.service to ensure PocketBase starts on server boot and recovers automatically from errors:
[Unit]
Description=PocketBase All-In-One Realtime Backend
After=network.target
[Service]
User=pocketbase
Group=pocketbase
Type=simple
WorkingDirectory=/var/www/pocketbase
ExecStart=/usr/local/bin/pocketbase serve --http=127.0.0.1:8090 --dir=/var/www/pocketbase/pb_data
Restart=always
RestartSec=3
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
Enable and start the service daemon:
sudo systemctl daemon-reload
sudo systemctl enable --now pocketbase
sudo systemctl status pocketbase --no-pager
Step 4: Nginx Reverse Proxy with Real-Time WebSockets & SSL
Expose the administrative UI and API endpoints over HTTPS by creating /etc/nginx/sites-available/pocketbase.example.com:
server {
listen 80;
server_name pocketbase.example.com;
client_max_body_size 50M;
location / {
proxy_pass http://127.0.0.1:8090;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 300s;
}
}
Enable the virtual host and acquire a free Let’s Encrypt SSL certificate:
sudo ln -s /etc/nginx/sites-available/pocketbase.example.com /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx
sudo certbot --nginx -d pocketbase.example.com
Step 5: Automated Daily SQLite Database Backup Script
Because SQLite stores all data in a single file (data.db), creating reliable, consistent backups during active writes is trivial using SQLite’s online backup API via PocketBase CLI:
# Create automated backup cron script (/usr/local/bin/backup-pocketbase.sh)
#!/bin/bash
set -e
BACKUP_DIR="/var/backups/pocketbase/$(date +%Y%m%d)"
mkdir -p $BACKUP_DIR
# Create atomic SQLite snapshot
/usr/local/bin/pocketbase backup create --dir=/var/www/pocketbase/pb_data
# Move and compress zip snapshot
mv /var/www/pocketbase/pb_data/backups/*.zip $BACKUP_DIR/
find /var/backups/pocketbase/ -type d -mtime +30 -exec rm -rf {} +
echo "PocketBase atomic backup completed successfully!"
PocketBase vs Supabase vs Firebase Comparison
| Feature / Spec | PocketBase | Supabase | Google Firebase |
|---|---|---|---|
| Architecture | Single Go Binary + SQLite | 11 Docker Containers + Postgres | Proprietary Cloud SaaS |
| Idle RAM Footprint | ~15 MB RAM | ~1,200 MB RAM | N/A (Managed Cloud) |
| Backup Simplicity | 1 Single .db file copy | pg_dumpall SQL export | Cloud snapshot exports |
Leveraging PocketBase JavaScript / Go Hooks & Extensibility
While PocketBase provides an intuitive no-code admin dashboard for creating collections, user authentication, and defining field rules, developers can write custom backend business logic using embedded JavaScript PB hooks in pb_hooks/:
// pb_hooks/main.pb.js - Custom API Endpoint & Event Interceptor
routerAdd("GET", "/api/v1/custom-stats", (c) => {
const totalUsers = $app.dao().findTotalRowsByFilter("users", "verified = true");
return c.json(200, {
"status": "healthy",
"verified_users": totalUsers,
"timestamp": new Date().toISOString()
});
});
// Automatically trigger welcome email upon new user registration
onModelAfterCreate((e) => {
if (e.model.tableName() === "users") {
$app.newMailClient().send({
from: { address: "[email protected]", name: "CpanelFree Cloud" },
to: [{ address: e.model.get("email") }],
subject: "Welcome to our platform!",
html: "Thank you for registering on our high-speed infrastructure."
});
}
}, "users");
Configuring S3-Compatible Object Storage for Uploads
If you prefer storing user file uploads on S3 object storage rather than local VPS SSD storage, configure S3 settings directly within the PocketBase Admin UI under Settings > Files storage > Use S3 storage:
- Endpoint:
https://s3.example.com(or AWS / Cloudflare R2) - Bucket Name:
app-attachments - Access Key & Secret Key: Your MinIO or AWS IAM credentials
Recommended Related Technical Guides
Host Lightweight App Backends on CpanelFree Cloud VPS
Scale your web and mobile applications with high-speed NVMe storage, dedicated memory channels, and 100% free hosting and VPS options.
🔗 Recommended Related Technical Guides:
- How to Host a Website for Free Forever: Complete Beginner Guide (2026)
- Top 5 Free WordPress Hosting Services with 1-Click Softaculous Installer
- How to Automatically Backup Your Linux VPS to Cloud Storage (S3 / Rclone Guide)
- How to Get a Free Cloud VPS Forever (Oracle, Google Cloud, AWS Free Tier)
- Explore $0 Free cPanel Web Hosting Plans (NVMe SSD, AutoSSL)
Deploy Fast, Reliable Web Hosting on CpanelFree
Get genuine cPanel control, unmetered NVMe SSD storage, and free AutoSSL at $0 cost forever.

