forked from
microcosm.blue/microcosm-rs
Constellation, Spacedust, Slingshot, UFOs: atproto crates and services for microcosm
1ufos ops
2
3btrfs snapshots: snapper
4
5```bash
6sudo apt install snapper
7sudo snapper -c ufos-db create-config /mnt/ufos-db
8
9# edit /etc/snapper/configs/ufos-db
10# change
11TIMELINE_MIN_AGE="1800"
12TIMELINE_LIMIT_HOURLY="10"
13TIMELINE_LIMIT_DAILY="10"
14TIMELINE_LIMIT_WEEKLY="0"
15TIMELINE_LIMIT_MONTHLY="10"
16TIMELINE_LIMIT_YEARLY="10"
17# to
18TIMELINE_MIN_AGE="1800"
19TIMELINE_LIMIT_HOURLY="22"
20TIMELINE_LIMIT_DAILY="4"
21TIMELINE_LIMIT_WEEKLY="0"
22TIMELINE_LIMIT_MONTHLY="0"
23TIMELINE_LIMIT_YEARLY="0"
24```
25
26this should be enough?
27
28list snapshots:
29
30```bash
31sudo snapper -c ufos-db list
32```
33
34systemd
35
36create file: `/etc/systemd/system/ufos.service`
37
38```ini
39[Unit]
40Description=UFOs-API
41After=network.target
42
43[Service]
44User=pi
45WorkingDirectory=/home/pi/
46ExecStart=/home/pi/ufos --jetstream us-west-2 --data /mnt/ufos-db/
47Environment="RUST_LOG=info"
48LimitNOFILE=16384
49Restart=always
50
51[Install]
52WantedBy=multi-user.target
53```
54
55then
56
57```bash
58sudo systemctl daemon-reload
59sudo systemctl enable ufos
60sudo systemctl start ufos
61```
62
63monitor with
64
65```bash
66journalctl -u ufos -f
67```
68
69make sure a backup dir exists
70
71```bash
72mkdir /home/pi/backup
73```
74
75mount the NAS
76
77```bash
78sudo mount.cifs "//truenas.local/folks data" /home/pi/backup -o user=phil,uid=pi
79```
80
81manual rsync
82
83```bash
84sudo rsync -ahP --delete /mnt/ufos-db/.snapshots/1/snapshot/ backup/ufos/
85```
86
87backup script sketch
88
89```bash
90NUM=$(sudo snapper --csvout -c ufos-db list --type single --columns number | tail -n1)
91sudo rsync -ahP --delete "/mnt/ufos-db/.snapshots/${NUM}/snapshot/" backup/ufos/
92```
93
94just crontab it?
95
96`sudo crontab -e`
97```bash
980 1/6 * * * rsync -ahP --delete "/mnt/ufos-db/.snapshots/$(sudo snapper --csvout -c ufos-db list --columns number | tail -n1)/snapshot/" backup/ufos/
99```
100
101^^ try once initial backup is done
102
103
104--columns subvolume,number
105
106subvolume
107number
108
109
110
111
112gateway: follow constellation for nginx->prom thing
113
114config at `/etc/prometheus-nginxlog-exporter.hcl`
115
116before: `/etc/prometheus-nginxlog-exporter.hcl`
117
118```hcl
119listen {
120 port = 4044
121}
122
123namespace "nginx" {
124 source = {
125 files = [
126 "/var/log/nginx/constellation-access.log"
127 ]
128 }
129
130 format = "$remote_addr - $remote_user [$time_local] \"$request\" $status $upstream_cache_status $body_bytes_sent \"$http_referer\" \"$http_user_agent\" \"$http_x_forwarded_for\""
131
132 labels {
133 app = "constellation"
134 }
135
136 relabel "cache_status" {
137 from = "upstream_cache_status"
138 }
139}
140```
141
142after:
143
144```hcl
145listen {
146 port = 4044
147}
148
149namespace "constellation" {
150 source = {
151 files = [
152 "/var/log/nginx/constellation-access.log"
153 ]
154 }
155
156 format = "$remote_addr - $remote_user [$time_local] \"$request\" $status $upstream_cache_status $body_bytes_sent \"$http_referer\" \"$http_user_agent\" \"$http_x_forwarded_for\""
157
158 labels {
159 app = "constellation"
160 }
161
162 relabel "cache_status" {
163 from = "upstream_cache_status"
164 }
165
166 namespace_label = "vhost"
167 metrics_override = { prefix = "nginx" }
168}
169
170namespace "ufos" {
171 source = {
172 files = [
173 "/var/log/nginx/ufos-access.log"
174 ]
175 }
176
177 format = "$remote_addr - $remote_user [$time_local] \"$request\" $status $upstream_cache_status $body_bytes_sent \"$http_referer\" \"$http_user_agent\" \"$http_x_forwarded_for\""
178
179 labels {
180 app = "ufos"
181 }
182
183 relabel "cache_status" {
184 from = "upstream_cache_status"
185 }
186
187 namespace_label = "vhost"
188 metrics_override = { prefix = "nginx" }
189}
190```
191
192
193```bash
194systemctl start prometheus-nginxlog-exporter.service
195```
196