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)
- Spin up a Digital Ocean droplet
- Download the Linux AMD64 binary
- Extract and upload the binary to your droplet
- Create a systemd service to run PocketBase continually
Steps
- Select a standard Ubuntu droplet; any size works for testing
- Visit the PocketBase releases page (e.g., https://github.com/pocketbase/pocketbase/releases) - Download the latest linuxamd64 zip file (e.g., pocketbase0.8.0linuxamd64.zip)
- 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@YOURDROPLETIP:/root/pb - The example above uploads the binary into the /root/pb directory on your droplet.
- 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
-------------------------------------------
- Enable and start the service: • sudo systemctl enable pocketbase.service --now
- 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.
- PocketBase stores data in the pbdata directory (by default in /root/pb/pbdata/) - 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
• ./pocketbase serve This will start a local server on 127.0.0.1:8090 for exploration.