Commit 7487b1a723
Verified · cmc
Layout: unified · split
content/blog/2026-04-22-self-hosting-zerobyte.org added +182
| @@ -0,0 +1,182 @@ | |||
| 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 | ||
| 8 | apps I've self hosted and the backup jobs are running smoothly. | ||
| 9 | |||
| 10 | In this post, I will show you how I've configured backups on my server to backup | ||
| 11 | data to Cloudflare R2. | ||
| 12 | |||
| 13 | * Installation | ||
| 14 | ** Docker | ||
| 15 | |||
| 16 | First, 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 | ||
| 20 | mkdir ~/zerobyte | ||
| 21 | cd ~/zerobyte | ||
| 22 | nano compose.yml | ||
| 23 | #+end_src | ||
| 24 | |||
| 25 | Next, paste the following content into the =compose.yml= file. You may want to | ||
| 26 | customize the =ports=, =environment=, and =volumes= sections. | ||
| 27 | |||
| 28 | #+begin_src yaml | ||
| 29 | services: | ||
| 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 | |||
| 50 | When you're done editing, launch the container. | ||
| 51 | |||
| 52 | #+begin_src bash | ||
| 53 | sudo docker compose up -d | ||
| 54 | #+end_src | ||
| 55 | |||
| 56 | At this point, you can access the app via [[http://localhost:4096]]. | ||
| 57 | |||
| 58 | ** Nginx | ||
| 59 | |||
| 60 | If you want to be able to access the app remotely, you'll need to utilize | ||
| 61 | something like a reverse proxy or tunnelling software. | ||
| 62 | |||
| 63 | This example uses Nginx as a reverse proxy. To start, edit a configuration file | ||
| 64 | in Nginx: | ||
| 65 | |||
| 66 | #+begin_src bash | ||
| 67 | cd /etc/nginx/conf.d | ||
| 68 | nano zb.conf | ||
| 69 | #+end_src | ||
| 70 | |||
| 71 | #+begin_src conf | ||
| 72 | server { | ||
| 73 | listen 80; | ||
| 74 | server_name zb.example.com; | ||
| 75 | location / { proxy_pass http://127.0.0.1:4096; } | ||
| 76 | } | ||
| 77 | #+end_src | ||
| 78 | |||
| 79 | Once you've created the file, test your Nginx configuration and restart the web | ||
| 80 | server. | ||
| 81 | |||
| 82 | #+begin_src bash | ||
| 83 | sudo nginx -t && sudo systemctl restart nginx.service | ||
| 84 | #+end_src | ||
| 85 | |||
| 86 | If your version of Nginx uses the =sites-available= structure instead, do this: | ||
| 87 | |||
| 88 | #+begin_src bash | ||
| 89 | cd /etc/nginx/sites-available | ||
| 90 | nano zb | ||
| 91 | # Edit the file | ||
| 92 | sudo ln -s /etc/nginx/sites-available/zb /etc/nginx/sites-enabled/zb | ||
| 93 | #+end_src | ||
| 94 | |||
| 95 | You may also need to provision a TLS/SSL certificate and add a =443= block to your | ||
| 96 | Nginx configuration above, if you wish to connect securely. | ||
| 97 | |||
| 98 | * Configuration | ||
| 99 | |||
| 100 | At this point, you will be able to access the app. Upon first login, you will | ||
| 101 | need to create an administrator account. | ||
| 102 | |||
| 103 | I 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 | ||
| 105 | your provider. | ||
| 106 | |||
| 107 | ** Volumes | ||
| 108 | |||
| 109 | First, create a volume. This is a file or directory on your server that you wish | ||
| 110 | to 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 | |||
| 115 | When you create a volume, you will be able to dictate the name, path, and type. | ||
| 116 | |||
| 117 | Remember to add a =volume= in your =compose.yml= file to ensure it's available | ||
| 118 | within the app! | ||
| 119 | |||
| 120 | #+CAPTION: Volume Configuration | ||
| 121 | [[https://img.cleberg.net/blog/20260422-self-hosting-zerobyte/volumes_02.webp]] | ||
| 122 | |||
| 123 | Finally, 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 | |||
| 130 | The next step is to connect to a remote repository. This example uses Cloudflare | ||
| 131 | R2 buckets. | ||
| 132 | |||
| 133 | #+CAPTION: Repositories List | ||
| 134 | [[https://img.cleberg.net/blog/20260422-self-hosting-zerobyte/repositories_01.webp]] | ||
| 135 | |||
| 136 | Within this configuration page, you can see the =Configuration= section in the | ||
| 137 | bottom-right detailing the connection information. | ||
| 138 | |||
| 139 | #+CAPTION: Repository Configuration | ||
| 140 | [[https://img.cleberg.net/blog/20260422-self-hosting-zerobyte/repositories_02.webp]] | ||
| 141 | |||
| 142 | When 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 | |||
| 147 | Within a snapshot, you can review information about the backup job that ran and | ||
| 148 | produced 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 | |||
| 155 | You can create any backup jobs (daily, weekly, monthly, specific days, or with a | ||
| 156 | cron 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 backup (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 | |||
| 168 | Within a backup job, you can configure the related notifications, snapshots, or | ||
| 169 | backup/edit/cleanup 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 | |||
| 176 | Lastly, you can enable various notification channels to receive alerts when jobs | ||
| 177 | start, fail, complete, etc. | ||
| 178 | |||
| 179 | I 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]] | ||