{"id":1871,"date":"2026-09-05T09:35:51","date_gmt":"2026-09-05T04:05:51","guid":{"rendered":"https:\/\/cpanelfree.com\/blog\/how-to-host-pocketbase-backend-single-binary-vps\/"},"modified":"2026-09-05T12:58:33","modified_gmt":"2026-09-05T07:28:33","slug":"how-to-host-pocketbase-backend-single-binary-vps","status":"publish","type":"post","link":"https:\/\/cpanelfree.com\/blog\/how-to-host-pocketbase-backend-single-binary-vps\/","title":{"rendered":"How to Self-Host PocketBase on Ubuntu VPS (Lightweight Realtime SQLite Backend)"},"content":{"rendered":"<h2>Why PocketBase Is the Ultimate Micro-Backend for Developers<\/h2>\n<p>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.<\/p>\n<p><strong>PocketBase<\/strong> is an open-source, all-in-one backend packaged as a <strong>single standalone Go binary<\/strong>. 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.<\/p>\n<p>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.<\/p>\n<h2>Step 1: Downloading and Installing the PocketBase Binary<\/h2>\n<p>PocketBase requires no external database daemons or complex language runtimes. Download the compiled Linux binary directly:<\/p>\n<pre><code># Create dedicated directory and download binary\nsudo mkdir -p \/var\/www\/pocketbase\ncd \/tmp\ncurl -LO https:\/\/github.com\/pocketbase\/pocketbase\/releases\/download\/v0.22.14\/pocketbase_0.22.14_linux_amd64.zip\n\n# Unzip binary and place into system PATH\nsudo apt update &amp;&amp; sudo apt install -y unzip nginx certbot python3-certbot-nginx\nunzip pocketbase_0.22.14_linux_amd64.zip\nsudo mv pocketbase \/usr\/local\/bin\/\nsudo chmod +x \/usr\/local\/bin\/pocketbase\n\n# Verify PocketBase CLI\npocketbase --version<\/code><\/pre>\n<h2>Step 2: Creating a Dedicated System User and Data Directory<\/h2>\n<p>For strict security isolation, never run web services as root:<\/p>\n<pre><code># Create dedicated system user\nsudo useradd --no-create-home --shell \/bin\/false pocketbase\nsudo chown -R pocketbase:pocketbase \/var\/www\/pocketbase\nsudo chmod 750 \/var\/www\/pocketbase<\/code><\/pre>\n<h2>Step 3: Configuring Systemd Service Daemon<\/h2>\n<p>Create a systemd unit at <code>\/etc\/systemd\/system\/pocketbase.service<\/code> to ensure PocketBase starts on server boot and recovers automatically from errors:<\/p>\n<pre><code>[Unit]\nDescription=PocketBase All-In-One Realtime Backend\nAfter=network.target\n\n[Service]\nUser=pocketbase\nGroup=pocketbase\nType=simple\nWorkingDirectory=\/var\/www\/pocketbase\nExecStart=\/usr\/local\/bin\/pocketbase serve --http=127.0.0.1:8090 --dir=\/var\/www\/pocketbase\/pb_data\nRestart=always\nRestartSec=3\nLimitNOFILE=65535\n\n[Install]\nWantedBy=multi-user.target<\/code><\/pre>\n<p>Enable and start the service daemon:<\/p>\n<pre><code>sudo systemctl daemon-reload\nsudo systemctl enable --now pocketbase\nsudo systemctl status pocketbase --no-pager<\/code><\/pre>\n<h2>Step 4: Nginx Reverse Proxy with Real-Time WebSockets &amp; SSL<\/h2>\n<p>Expose the administrative UI and API endpoints over HTTPS by creating <code>\/etc\/nginx\/sites-available\/pocketbase.example.com<\/code>:<\/p>\n<pre><code>server {\n    listen 80;\n    server_name pocketbase.example.com;\n\n    client_max_body_size 50M;\n\n    location \/ {\n        proxy_pass http:\/\/127.0.0.1:8090;\n        proxy_http_version 1.1;\n        proxy_set_header Upgrade $http_upgrade;\n        proxy_set_header Connection \"upgrade\";\n        proxy_set_header Host $host;\n        proxy_set_header X-Real-IP $remote_addr;\n        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n        proxy_set_header X-Forwarded-Proto $scheme;\n        proxy_read_timeout 300s;\n    }\n}<\/code><\/pre>\n<p>Enable the virtual host and acquire a free Let&#8217;s Encrypt SSL certificate:<\/p>\n<pre><code>sudo ln -s \/etc\/nginx\/sites-available\/pocketbase.example.com \/etc\/nginx\/sites-enabled\/\nsudo nginx -t &amp;&amp; sudo systemctl reload nginx\nsudo certbot --nginx -d pocketbase.example.com<\/code><\/pre>\n<h2>Step 5: Automated Daily SQLite Database Backup Script<\/h2>\n<p>Because SQLite stores all data in a single file (<code>data.db<\/code>), creating reliable, consistent backups during active writes is trivial using SQLite&#8217;s online backup API via PocketBase CLI:<\/p>\n<pre><code># Create automated backup cron script (\/usr\/local\/bin\/backup-pocketbase.sh)\n#!\/bin\/bash\nset -e\nBACKUP_DIR=\"\/var\/backups\/pocketbase\/$(date +%Y%m%d)\"\nmkdir -p $BACKUP_DIR\n\n# Create atomic SQLite snapshot\n\/usr\/local\/bin\/pocketbase backup create --dir=\/var\/www\/pocketbase\/pb_data\n\n# Move and compress zip snapshot\nmv \/var\/www\/pocketbase\/pb_data\/backups\/*.zip $BACKUP_DIR\/\nfind \/var\/backups\/pocketbase\/ -type d -mtime +30 -exec rm -rf {} +\necho \"PocketBase atomic backup completed successfully!\"<\/code><\/pre>\n<h2>PocketBase vs Supabase vs Firebase Comparison<\/h2>\n<table style=\"width: 100%;border-collapse: collapse;margin: 20px 0;border: 1px solid #334155\">\n<thead>\n<tr style=\"background-color: #0f172a;color: #38bdf8\">\n<th style=\"padding: 12px;border: 1px solid #334155\">Feature \/ Spec<\/th>\n<th style=\"padding: 12px;border: 1px solid #334155\">PocketBase<\/th>\n<th style=\"padding: 12px;border: 1px solid #334155\">Supabase<\/th>\n<th style=\"padding: 12px;border: 1px solid #334155\">Google Firebase<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr style=\"background-color: #1e293b;color: #f8fafc\">\n<td style=\"padding: 10px;border: 1px solid #334155\"><strong>Architecture<\/strong><\/td>\n<td style=\"padding: 10px;border: 1px solid #334155\"><strong>Single Go Binary + SQLite<\/strong><\/td>\n<td style=\"padding: 10px;border: 1px solid #334155\">11 Docker Containers + Postgres<\/td>\n<td style=\"padding: 10px;border: 1px solid #334155\">Proprietary Cloud SaaS<\/td>\n<\/tr>\n<tr style=\"background-color: #0f172a;color: #f8fafc\">\n<td style=\"padding: 10px;border: 1px solid #334155\"><strong>Idle RAM Footprint<\/strong><\/td>\n<td style=\"padding: 10px;border: 1px solid #334155\"><strong>~15 MB RAM<\/strong><\/td>\n<td style=\"padding: 10px;border: 1px solid #334155\">~1,200 MB RAM<\/td>\n<td style=\"padding: 10px;border: 1px solid #334155\">N\/A (Managed Cloud)<\/td>\n<\/tr>\n<tr style=\"background-color: #1e293b;color: #f8fafc\">\n<td style=\"padding: 10px;border: 1px solid #334155\"><strong>Backup Simplicity<\/strong><\/td>\n<td style=\"padding: 10px;border: 1px solid #334155\"><strong>1 Single .db file copy<\/strong><\/td>\n<td style=\"padding: 10px;border: 1px solid #334155\">pg_dumpall SQL export<\/td>\n<td style=\"padding: 10px;border: 1px solid #334155\">Cloud snapshot exports<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Leveraging PocketBase JavaScript \/ Go Hooks &amp; Extensibility<\/h2>\n<p>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 <code>pb_hooks\/<\/code>:<\/p>\n<pre><code>\/\/ pb_hooks\/main.pb.js - Custom API Endpoint &amp; Event Interceptor\nrouterAdd(\"GET\", \"\/api\/v1\/custom-stats\", (c) =&gt; {\n    const totalUsers = $app.dao().findTotalRowsByFilter(\"users\", \"verified = true\");\n    return c.json(200, {\n        \"status\": \"healthy\",\n        \"verified_users\": totalUsers,\n        \"timestamp\": new Date().toISOString()\n    });\n});\n\n\/\/ Automatically trigger welcome email upon new user registration\nonModelAfterCreate((e) =&gt; {\n    if (e.model.tableName() === \"users\") {\n        $app.newMailClient().send({\n            from: { address: \"no-reply@cpanelfree.com\", name: \"CpanelFree Cloud\" },\n            to: [{ address: e.model.get(\"email\") }],\n            subject: \"Welcome to our platform!\",\n            html: \"Thank you for registering on our high-speed infrastructure.\"\n        });\n    }\n}, \"users\");<\/code><\/pre>\n<h2>Configuring S3-Compatible Object Storage for Uploads<\/h2>\n<p>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 <strong>Settings &gt; Files storage &gt; Use S3 storage<\/strong>:<\/p>\n<ul>\n<li><strong>Endpoint:<\/strong> <code>https:\/\/s3.example.com<\/code> (or AWS \/ Cloudflare R2)<\/li>\n<li><strong>Bucket Name:<\/strong> <code>app-attachments<\/code><\/li>\n<li><strong>Access Key &amp; Secret Key:<\/strong> Your MinIO or AWS IAM credentials<\/li>\n<\/ul>\n<div style=\"background-color: #0f172a;border-left: 4px solid #38bdf8;padding: 18px 24px;margin: 30px 0;border-radius: 8px\">\n<h3 style=\"color: #38bdf8;margin-top: 0\">Recommended Related Technical Guides<\/h3>\n<ul style=\"margin-bottom: 0;color: #cbd5e1\">\n<li><a href=\"https:\/\/cpanelfree.com\/blog\/how-to-self-host-supabase-alternative-firebase-vps\/\" style=\"color: #38bdf8;text-decoration: underline\">Self-Hosting Supabase Backend on Ubuntu VPS<\/a><\/li>\n<li><a href=\"https:\/\/cpanelfree.com\/blog\/how-to-deploy-nextjs-app-ubuntu-vps-pm2-nginx\/\" style=\"color: #38bdf8;text-decoration: underline\">Deploying Next.js Frontends on Cloud VPS<\/a><\/li>\n<li><a href=\"https:\/\/cpanelfree.com\/blog\/how-to-secure-linux-vps-fail2ban-ufw-ssh\/\" style=\"color: #38bdf8;text-decoration: underline\">Securing Linux Cloud VPS with UFW and Fail2ban<\/a><\/li>\n<\/ul>\n<\/div>\n<div style=\"background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);color: #ffffff;padding: 28px;border-radius: 12px;margin: 35px 0;text-align: center\">\n<h3 style=\"color: #ffffff;margin-top: 0;font-size: 22px\">Host Lightweight App Backends on CpanelFree Cloud VPS<\/h3>\n<p style=\"color: #e0f2fe;font-size: 15px;max-width: 650px;margin: 0 auto 18px auto\">Scale your web and mobile applications with high-speed NVMe storage, dedicated memory channels, and 100% free hosting and VPS options.<\/p>\n<p>  <a href=\"https:\/\/cpanelfree.com\/\" style=\"background-color: #ffffff;color: #0284c7;font-weight: 700;padding: 12px 28px;border-radius: 8px;text-decoration: none;display: inline-block\">Get Free Cloud Hosting Today &rarr;<\/a>\n<\/div>\n<div style=\"border-left: 4px solid #38bdf8;border-radius: 8px;padding: 20px;margin: 30px 0\">\n<h3 style=\"margin-top: 0;color: #38bdf8;font-size: 18px;display: flex;align-items: center\">\n        <span style=\"margin-right: 8px\">\ud83d\udd17<\/span> Recommended Related Technical Guides:<br \/>\n    <\/h3>\n<ul style=\"margin: 10px 0 0 0;padding-left: 20px;line-height: 1.8\">\n<li><a href=\"https:\/\/cpanelfree.com\/blog\/how-to-host-website-free-forever-guide\/\" style=\"color: #38bdf8;text-decoration: none;font-weight: 600\">How to Host a Website for Free Forever: Complete Beginner Guide (2026)<\/a><\/li>\n<li><a href=\"https:\/\/cpanelfree.com\/blog\/free-wordpress-hosting-softaculous-installer\/\" style=\"color: #38bdf8;text-decoration: none;font-weight: 600\">Top 5 Free WordPress Hosting Services with 1-Click Softaculous Installer<\/a><\/li>\n<li><a href=\"https:\/\/cpanelfree.com\/blog\/how-to-backup-linux-vps-to-cloud-storage-s3-rclone\/\" style=\"color: #38bdf8;text-decoration: none;font-weight: 600\">How to Automatically Backup Your Linux VPS to Cloud Storage (S3 \/ Rclone Guide)<\/a><\/li>\n<li><a href=\"https:\/\/cpanelfree.com\/blog\/how-to-get-free-cloud-vps-forever\/\" style=\"color: #38bdf8;text-decoration: none;font-weight: 600\">How to Get a Free Cloud VPS Forever (Oracle, Google Cloud, AWS Free Tier)<\/a><\/li>\n<li><a href=\"https:\/\/cpanelfree.com\/#plans\" style=\"color: #10b981;text-decoration: none;font-weight: 600\">Explore $0 Free cPanel Web Hosting Plans (NVMe SSD, AutoSSL)<\/a><\/li>\n<\/ul>\n<\/div>\n<div style=\"background: linear-gradient(135deg, rgba(6, 182, 212, 0.15) 0%, rgba(59, 130, 246, 0.15) 100%);border-radius: 12px;padding: 25px;margin: 30px 0;text-align: center\">\n<h3 style=\"color: #38bdf8;margin-top: 0;font-size: 20px\">Deploy Fast, Reliable Web Hosting on CpanelFree<\/h3>\n<p style=\"color: #94a3b8;font-size: 14px;line-height: 1.6;max-width: 600px;margin: 0 auto 15px\">\n        Get genuine cPanel control, unmetered NVMe SSD storage, and free AutoSSL at $0 cost forever.\n    <\/p>\n<p>    <a href=\"https:\/\/cpanelfree.com\/#plans\" style=\"display: inline-block;background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);color: #ffffff;padding: 10px 22px;border-radius: 6px;text-decoration: none;font-weight: bold;font-size: 14px\">Claim Free Hosting Account<\/a>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2502,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[166],"tags":[],"class_list":["post-1871","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-developer-stacks"],"_links":{"self":[{"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/posts\/1871","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/comments?post=1871"}],"version-history":[{"count":2,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/posts\/1871\/revisions"}],"predecessor-version":[{"id":2302,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/posts\/1871\/revisions\/2302"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/media\/2502"}],"wp:attachment":[{"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/media?parent=1871"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/categories?post=1871"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/tags?post=1871"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}