cmc/cleberg.net

My personal web garden & blog.

clone: git clone https://gitbay.org/cmc/cleberg.net.git

main: content/blog/2026-04-22-self-hosting-zerobyte.org · raw

  1#+date: [2026-04-22 Wed 09:59:21]
  2#+title: Automating Backups with Zerobyte & Cloudflare R2
  3#+description: Learn how to self-host Zerobyte and automate your backups!
  4#+slug: self-hosting-zerobyte
  5#+filetags: :self-hosting:
  6
  7[[https://zerobyte.app][Zerobyte]] is a slick backup solution you can self host. It's one of the easiest
  8apps I've self hosted and the backup jobs are running smoothly.
  9
 10In this post, I will show you how I've configured backups on my server to back up
 11data to Cloudflare R2.
 12
 13* Installation
 14** Docker
 15
 16First, let's install the app with Docker Compose. Create a directory for your
 17=compose.yml= file in a location you'll remember.
 18
 19#+begin_src bash
 20mkdir ~/zerobyte
 21cd ~/zerobyte
 22nano compose.yml
 23#+end_src
 24
 25Next, paste the following content into the =compose.yml= file. You may want to
 26customize the =ports=, =environment=, and =volumes= sections.
 27
 28#+begin_src yaml
 29services:
 30  zerobyte:
 31    image: ghcr.io/nicotsx/zerobyte:v0.30
 32    container_name: zerobyte
 33    restart: unless-stopped
 34    cap_add:
 35      - SYS_ADMIN
 36    ports:
 37      - "4096:4096"
 38    devices:
 39      - /dev/fuse:/dev/fuse
 40    environment:
 41      - TZ=America/Chicago
 42      - BASE_URL=https://zb.example.com
 43      - APP_SECRET=...
 44    volumes:
 45      - /etc/localtime:/etc/localtime:ro
 46      - /var/lib/zerobyte:/var/lib/zerobyte
 47      - /path/to/backup:/path/to/backup
 48#+end_src
 49
 50When you're done editing, launch the container.
 51
 52#+begin_src bash
 53sudo docker compose up -d
 54#+end_src
 55
 56At this point, you can access the app via [[http://localhost:4096]].
 57
 58** Nginx
 59
 60If you want to be able to access the app remotely, you'll need to utilize
 61something like a reverse proxy or tunneling software.
 62
 63This example uses Nginx as a reverse proxy. To start, edit a configuration file
 64in Nginx:
 65
 66#+begin_src bash
 67cd /etc/nginx/conf.d
 68nano zb.conf
 69#+end_src
 70
 71#+begin_src conf
 72server {
 73    listen 80;
 74    server_name zb.example.com;
 75    location / { proxy_pass http://127.0.0.1:4096; }
 76}
 77#+end_src
 78
 79Once you've created the file, test your Nginx configuration and restart the web
 80server.
 81
 82#+begin_src bash
 83sudo nginx -t && sudo systemctl restart nginx.service
 84#+end_src
 85
 86If your version of Nginx uses the =sites-available= structure instead, do this:
 87
 88#+begin_src bash
 89cd /etc/nginx/sites-available
 90nano zb
 91# Edit the file
 92sudo ln -s /etc/nginx/sites-available/zb /etc/nginx/sites-enabled/zb
 93#+end_src
 94
 95You may also need to provision a TLS/SSL certificate and add a =443= block to your
 96Nginx configuration above, if you wish to connect securely.
 97
 98* Configuration
 99
100At this point, you will be able to access the app. Upon first login, you will
101need to create an administrator account.
102
103I won't be diving fully into the setup process. I highly suggest reading the
104[[https://zerobyte.app/docs][Zerobyte Docs]]. They are very helpful and will walk you through the setup for
105your provider.
106
107** Volumes
108
109First, create a volume. This is a file or directory on your server that you wish
110to back up. You can see I have two directories connected as volumes.
111
112#+CAPTION: Volumes List
113[[https://img.cleberg.net/blog/20260422-self-hosting-zerobyte/volumes_01.webp]]
114
115When you create a volume, you will be able to dictate the name, path, and type.
116
117Remember to add a =volume= in your =compose.yml= file to ensure it's available
118within the app!
119
120#+CAPTION: Volume Configuration
121[[https://img.cleberg.net/blog/20260422-self-hosting-zerobyte/volumes_02.webp]]
122
123Finally, you can inspect the files within your volume.
124
125#+CAPTION: Volume Files
126[[https://img.cleberg.net/blog/20260422-self-hosting-zerobyte/volumes_03.webp]]
127
128** Repositories
129
130The next step is to connect to a remote repository. This example uses Cloudflare
131R2 buckets.
132
133#+CAPTION: Repositories List
134[[https://img.cleberg.net/blog/20260422-self-hosting-zerobyte/repositories_01.webp]]
135
136Within this configuration page, you can see the =Configuration= section in the
137bottom-right detailing the connection information.
138
139#+CAPTION: Repository Configuration
140[[https://img.cleberg.net/blog/20260422-self-hosting-zerobyte/repositories_02.webp]]
141
142When each backup runs, it produces a snapshot that you can view and explore.
143
144#+CAPTION: Repository Snapshots
145[[https://img.cleberg.net/blog/20260422-self-hosting-zerobyte/repositories_03.webp]]
146
147Within a snapshot, you can review information about the backup job that ran and
148produced the snapshot, as well as the files at that point in time.
149
150#+CAPTION: Snapshot Details
151[[https://img.cleberg.net/blog/20260422-self-hosting-zerobyte/repositories_04.webp]]
152
153** Backups
154
155You can create any backup jobs (daily, weekly, monthly, specific days, or with a
156cron pattern). This allows you to specify:
157- The volume to be backed up
158- The repository to back up to
159- The schedule
160- The files to back up (all will be backed up if nothing is specifically selected)
161- Include/exclude patterns
162- Retention policies
163- Custom restic patterns
164
165#+CAPTION: Backup Jobs
166[[https://img.cleberg.net/blog/20260422-self-hosting-zerobyte/backups_01.webp]]
167
168Within a backup job, you can configure the related notifications, snapshots, or
169back up, edit, or clean up the job.
170
171#+CAPTION: Backup Job Details
172[[https://img.cleberg.net/blog/20260422-self-hosting-zerobyte/backups_02.webp]]
173
174** Notifications
175
176Lastly, you can enable various notification channels to receive alerts when jobs
177start, fail, complete, etc.
178
179I have used an SMTP email provider to send myself emails upon these points.
180
181#+CAPTION: Notification Settings
182[[https://img.cleberg.net/blog/20260422-self-hosting-zerobyte/notifications.webp]]