Skip to content

Instantly share code, notes, and snippets.

@garyblankenship
Created March 25, 2025 16:51
Show Gist options
  • Save garyblankenship/cf1c24e3c1150bd528bf6f757a4fc1c0 to your computer and use it in GitHub Desktop.
Save garyblankenship/cf1c24e3c1150bd528bf6f757a4fc1c0 to your computer and use it in GitHub Desktop.
How To Install PocketBase on Digital Ocean

How To Install PocketBase on Digital Ocean

Prerequisites

  • A Digital Ocean account with an Ubuntu droplet (even the smallest $4 option works)
  • Basic knowledge of using the command line and SSH
  • A domain or subdomain (optional, for accessible URL with SSL)

Steps

  1. Spin up a Digital Ocean droplet
    • Select a standard Ubuntu droplet; any size works for testing
  2. Download the Linux AMD64 binary
  3. Extract and upload the binary to your droplet
    • Unzip the downloaded file on your local machine; it will produce two files: LICENSE and the executable “pocketbase”
    • Use rsync (or your preferred upload method) to transfer the binary to your droplet directory. For example: • rsync -avz -e ssh /local/path/to/pocketbase root@YOUR_DROPLET_IP:/root/pb
    • The example above uploads the binary into the /root/pb directory on your droplet.
  4. Create a systemd service to run PocketBase continually
    • Open or create a new service file: • sudo vi /lib/systemd/system/pocketbase.service

    • Paste in the following content (replace yourdomain.com with your actual domain or subdomain):

      [Unit] Description = PocketBase Service

      [Service] Type = simple User = root Group = root LimitNOFILE = 4096 Restart = always RestartSec = 5s StandardOutput = append:/root/pb/errors.log StandardError = append:/root/pb/errors.log ExecStart = /root/pb/pocketbase serve --http="yourdomain.com:80" --https="yourdomain.com:443"

      [Install] WantedBy = multi-user.target

    • Save and close the file.

    • Enable and start the service: • sudo systemctl enable pocketbase.service --now

  5. Assign a readable URL
    • Instead of using an IP address, point your domain/subdomain to the droplet’s IP by configuring DNS via Digital Ocean’s networking tools (see DigitalOcean docs for adding domains)
    • PocketBase’s built-in HTTPS handling (via Let’s Encrypt) will work when your actual domain name is used in the service config.
  6. Backup your PocketBase data
    • PocketBase stores data in the pb_data directory (by default in /root/pb/pb_data/)
    • For regular backups, consider using a tool like rclone combined with a cron job to periodically sync your pb_data folder to backup storage (such as DO Spaces)
    • Alternatively, tools like Litestream (for SQLite backups) can be explored

Tips

  • Make sure to leave SSH (port 22) open when configuring UFW/firewall rules. For example: sudo ufw allow 22/tcp
  • Although some may suggest using nginx or Apache as a reverse proxy, PocketBase includes its own HTTP/HTTPS server with automated certificate provisioning; you don’t need an additional web server for basic setups.
  • Test your installation locally before deploying to production by running: • ./pocketbase serve This will start a local server on 127.0.0.1:8090 for exploration.

Next Steps

  • Monitor the logs in /root/pb/errors.log to catch any issues early
  • Experiment with PocketBase features locally and adjust your production configuration as needed
  • Enhance security (e.g., update system packages, restrict file permissions) for a production environment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment