fixes
[distro-setup] / btrbk-run
1 #!/bin/bash
2 # Copyright (C) 2016 Ian Kelling
3
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7
8 # http://www.apache.org/licenses/LICENSE-2.0
9
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16
17 # todo: if we cancel in the middle of a btrfs send, then run again
18 # immediately, the received subvolume doesn't get a Received UUID:
19 # field, and we won't mount it. Need to figure out a solution that will
20 # fix this.
21
22
23 [[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@"
24
25 source /usr/local/lib/err
26
27 usage() {
28 cat <<'EOF'
29 btrbk-run [OPTIONS] [run|resume|archive]
30 usually -t TARGET_HOST or -s SOURCE_HOST
31
32 Note, at source location, intentionally not executable, run and read
33 install-my-scripts.
34
35 EOF
36 echo "top of script file:"
37 sed -n '1,/^[# ]*end command line/{p;b};q' "$0"
38 exit $1
39 }
40
41
42
43 script_name="${BASH_SOURCE[0]}"
44 script_name="${script_name##*/}"
45 pre="${SSH_CLIENT:+$HOSTNAME} $script_name:"
46 m() { if $verbose; then printf "$pre%s\n" "$*"; fi; "$@"; }
47 e() { printf "$pre%s\n" "$*"; }
48 die() { printf "$pre%s\n" "$*" >&2; echo "exiting with status 1" >&2; exit 1; }
49 mexit() { echo "$pre: exiting with status $1"; exit $1; }
50
51 # latest $MAIL_HOST
52 if [[ -e /b/bash_unpublished/source-state ]]; then
53 source /b/bash_unpublished/source-state
54 fi
55
56 # note q is owned by root:1000
57
58 mountpoints=()
59
60 rsync_mountpoint=/q
61
62 ret=0
63 # default options
64 conf_only=false
65 dry_run=false # mostly for testing
66 rate_limit=no
67 verbose=true; verbose_arg=-v
68 if [[ $INVOCATION_ID ]]; then
69 # INVOCATION_ID means running as a systemd service. we cant show progress in this case,
70 # but if we pass the arg, it will insert mbuffer into the command.
71 progress_arg=
72 else
73 progress_arg="--progress"
74 fi
75 incremental_strict=false
76 pull_reexec=false
77
78 default_args_file=/etc/btrbk-run.conf
79 if [[ -s $default_args_file ]]; then
80 # shellcheck disable=SC2046 # we want word splitting
81 set -- $(< $default_args_file) "$@"
82 # i havent used this feature yet, so warn about it
83 echo "$0: warning: default btrbk-run options set in $default_args_file (sleeping 5 seconds):"
84 cat $default_args_file
85 sleep 5
86 fi
87
88 targets=()
89 early=false
90 cron=false
91 fast=false
92 kd_spread_maybe=false
93 orig_args=("$@")
94 temp=$(getopt -l cron,fast,pull-reexec,help 23ceikl:m:npqrs:t:vh "$@") || usage 1
95 eval set -- "$temp"
96 while true; do
97 case $1 in
98 # some behaviors specific to running under cron:
99 # - skip hosts where xprintidle haven't been idle recently
100 # - if we can't ssh to 1 or more hosts, still do the rest
101 # - if we aren't MAIL_HOST and no -m or -s, just exit
102 --cron)
103 cron=true
104 pre=
105 ;;
106 # for the rare case we want to run multiple instances at the same time
107 -2) conf_suf=2 ;;
108 -3) conf_suf=3 ;;
109 # only creates the config file, does not run btrbk
110 -c) conf_only=true ;;
111 # quit early, just btrbk, no extra remounting etc.
112 -e) early=true ;;
113 # skip various checks. when we run twice in a row for
114 # switch mail-host, no need to repeat the same checks again.
115 --fast) fast=true ;;
116 -i) incremental_strict=true ;;
117 # note this implies resume
118 -k) kd_spread_maybe=true ;;
119 # bytes per second, suffix k m g
120 -l) rate_limit=$2; shift ;;
121 # Comma separated mountpoints to backup. This has defaults set below.
122 -m) IFS=, mountpoints=($2); unset IFS; shift ;;
123 -n) dry_run=true ;;
124 # hide progress
125 -p) progress_arg= ;;
126 # internal option for rerunning under newer SOURCE_HOST version.
127 --pull-reexec) pull_reexec=true;;
128 # quiet
129 -q) verbose=false; verbose_arg=; progress_arg= ;;
130 # source host to receive a backup from
131 -s)
132 source=$2
133 bbksource=$source
134 if [[ $source == *:* ]]; then
135 bbksource="[$source]"
136 fi
137 shift
138 ;;
139 # target hosts to send to. empty is valid for just doing local
140 # snapshot. we have default hosts we will populate.
141 -t) IFS=, targets=($2); unset IFS; shift ;;
142 # verbose.
143 -v) verbose=true; verbose_arg=-v ;;
144 -h|--help) usage ;;
145 --) shift; break ;;
146 *) die "Internal error!" ;;
147 esac
148 shift
149 done
150
151 if $kd_spread_maybe; then
152 if [[ $1 && $1 != resume ]]; then
153 die "dont pass -k without resume or empty run arg"
154 fi
155 cmd_arg=resume
156 fi
157
158
159 cmd_arg=${1:-run}
160
161
162 std_preserve="36h 14d 8w 24m"
163 q_preserve="18h 14d 8w"
164
165 case $cmd_arg in
166 run|resume) : ;;
167
168 # This works better than the normal archive command. We have to
169 # specify the mount points, but that is what we are used to doing and
170 # we prefer it. Another difference is that archive works recursively
171 # and we don't care about that. Sometimes we may still want to run
172 # btrbk archive, but it doesn't even use the config file, so just
173 # run it directly, eg:
174 # time s btrbk -v archive /mnt/r7/amy/boot/btrbk ssh://bo/mnt/boot2/btrbk
175 archive)
176 cmd_arg=resume
177 std_preserve="999h 999d 999w 999m"
178 q_preserve="$std_preserve"
179 preserve_arg=-p
180 ;;
181 *) die "untested command arg" ;;
182 esac
183
184 if (( $# > 1 )); then
185 die: "only 1 nonoption arg is supported"
186 fi
187
188 if [[ -v targets && $source ]]; then
189 # note, this doesnt need to be the case, but
190 # we would need to think about it.
191 die "error: -t and -s are mutually exclusive"
192 fi
193
194 ### end options parsing
195
196 # remove path from earlier version of btrbk
197 rm -f /usr/sbin/btrbk
198 # note, this still works as intended if there is no /usr/bin/btrbk
199 if [[ /a/opt/btrbk/btrbk -nt /usr/bin/btrbk ]]; then
200 if [[ -e /b/distro-functions/src/package-manager-abstractions ]]; then
201 . /b/distro-functions/src/package-manager-abstractions
202 pi asciidoctor
203 fi
204 cd /a/opt/btrbk
205 m make install
206 fi
207
208 # TODO: i wonder if there should be an option to send to the default
209 # targets, plus any given on the command line.
210
211
212
213 kd_spread=false
214 # set default targets
215 if [[ ! -v targets && ! $source ]]; then
216 if $cron; then
217 if [[ $HOSTNAME != "$MAIL_HOST" ]]; then
218 if $kd_spread_maybe && [[ $HOSTNAME == kd && $MAIL_HOST == x3 ]]; then
219 if ping -q -c1 -w1 x3.office.fsf.org &>/dev/null; then
220 work_host=x3.office.fsf.org
221 elif ping -q -c1 -w1 x3wg.b8.nz &>/dev/null; then
222 work_host=x3wg.b8.nz
223 fi
224 if [[ $work_host ]]; then
225 source_state="$(ssh $work_host cat /a/bin/bash_unpublished/source-state)"
226 eval "$source_state"
227 if [[ $MAIL_HOST == x3 ]]; then
228 kd_spread=true
229 else
230 echo "MAIL_HOST=$MAIL_HOST, nothing to do"
231 mexit 0
232 fi
233 else
234 echo "MAIL_HOST=$MAIL_HOST, nothing to do"
235 mexit 0
236 fi
237 else
238 echo "MAIL_HOST=$MAIL_HOST, nothing to do"
239 mexit 0
240 fi
241 fi
242 fi
243
244 at_work=false
245 at_home=false
246
247 case $HOSTNAME in
248 kw|kd|frodo|x2|x3|sy) : ;;
249 *)
250 die "error: no default targets for this host, use -t"
251 ;;
252 esac
253
254 case $HOSTNAME in
255 kw)
256 at_work=true
257 ;;&
258 kd|frodo)
259 at_home=true
260 ;;&
261 x2|x3|sy)
262 if [[ $(dig +short @10.2.0.1 -x 10.2.0.2 2>&1 ||:) == kd.b8.nz. ]] \
263 && ip n show 10.2.0.1 | grep . &>/dev/null; then
264 at_home=true
265 elif ping -q -c1 -w1 hal.office.fsf.org &>/dev/null \
266 && ip n show 192.168.0.26 | grep . &>/dev/null; then
267 at_work=true
268 fi
269 ;;&
270 *)
271 if $at_home; then
272 if ! $kd_spread && [[ $HOSTNAME != x3 ]]; then
273 # main work machine
274 if ping -q -c1 -w1 x3.office.fsf.org &>/dev/null; then
275 targets+=(x3.office.fsf.org)
276 elif ping -q -c1 -w1 $h.b8.nz &>/dev/null; then
277 # in case we took it home
278 targets+=(x3.b8.nz)
279 else
280 targets+=(x3wg.b8.nz)
281 fi
282 fi
283 # temporarily disabled while doing recovery
284 # for h in frodo kd; do
285 for h in kd; do
286 if [[ $HOSTNAME == "$h" ]]; then
287 continue
288 fi
289 targets+=($h.b8.nz)
290 done
291 for h in x2 sy; do
292 if [[ $HOSTNAME == "$h" ]]; then
293 continue
294 fi
295 if ping -q -c1 -w1 $h.b8.nz &>/dev/null; then
296 targets+=($h.b8.nz)
297 elif ping -q -c1 -w1 ${h}w.b8.nz &>/dev/null; then
298 targets+=(${h}w.b8.nz)
299 fi
300 done
301 elif $at_work; then
302 if ping -q -c1 -w1 iank.vpn.office.fsf.org &>/dev/null; then
303 targets+=(iank.vpn.office.fsf.org)
304 else
305 targets+=(i.b8.nz)
306 fi
307 for h in x2 x3 kw; do
308 if [[ $HOSTNAME == "$h" ]]; then
309 continue
310 fi
311 if ping -q -c1 -w1 $h.office.fsf.org &>/dev/null; then
312 targets+=($h.office.fsf.org)
313 fi
314 done
315 else
316 targets+=(i.b8.nz)
317 fi
318 ;;
319 esac
320 fi
321
322 if $verbose; then
323 printf "$pre options: conf_only=%s\ndry_run=%s\nrate_limit=%s\nverbose=%s\ncmd_arg=%s" "$conf_only" "$dry_run" "$rate_limit" "$verbose" "$cmd_arg"
324 fi
325
326
327 if [[ -v targets ]]; then
328 echo "targets: ${targets[*]}"
329 fi
330
331 if [[ $source ]]; then
332 echo "source: $source"
333 fi
334
335 if [[ ${mountpoints[0]} ]]; then
336 for mp in ${mountpoints[@]}; do
337 if [[ -e /nocow/btrfs-stale/$mp ]]; then
338 die "error: $mp is stale, mount-latest-subvol first"
339 fi
340 done
341 else
342 # set default mountpoints
343 if [[ ${targets[0]} == tp ]]; then
344 prospective_mps=(/a)
345 else
346 case $HOSTNAME in
347 *)
348 prospective_mps=()
349 if [[ $source ]]; then
350 source_state="$(ssh $source cat /a/bin/bash_unpublished/source-state)"
351 eval "$source_state"
352 source_host="$(ssh $source cat /etc/hostname)"
353 if [[ $source_host == "$MAIL_HOST" ]]; then
354 prospective_mps+=(/o)
355 fi
356 if [[ $source_host == "$HOST2" ]]; then
357 prospective_mps+=(/a /ar /qr /q)
358 fi
359 else
360 if [[ $HOSTNAME == "$MAIL_HOST" ]]; then
361 prospective_mps+=(/o)
362 fi
363 if [[ $HOSTNAME == "$HOST2" ]]; then
364 prospective_mps+=(/a /ar /qr /q)
365 fi
366 if $kd_spread; then
367 prospective_mps=(/a /ar /o /qr /q)
368 fi
369 fi
370 # note: put q last just in case its specific retention options were to
371 # affect other config sections. I havent tested if that is the case.
372 ;;
373 esac
374 fi
375 for mp in ${prospective_mps[@]}; do # default mountpoints to sync
376 if [[ -e /nocow/btrfs-stale/$mp ]]; then
377 e "warning: $mp stale, not adding to default mountpoints"
378 continue
379 fi
380 if awk '{print $2}' /etc/fstab | grep -xF $mp &>/dev/null; then
381 mountpoints+=($mp)
382 fi
383 done
384 fi
385
386 if (( ! ${#mountpoints[@]} )); then
387 die didnt get mountpoint arg and had no defaults
388 fi
389
390 echo "mountpoints: ${mountpoints[*]}"
391
392 ##### end command line parsing ########
393
394 # todo: this has a timing problem, since btrbk.timer could activate the service after this check.
395 if ! $fast && [[ $source ]]; then
396 if [[ $(ssh $source ps --no-headers -o comm 1) == systemd ]]; then
397 status=$(ssh $source systemctl is-active btrbk.service) || : # normally returns 3
398 case $status in
399 inactive|failed) : ;;
400 *)
401 echo "$0: error: cron btrbk is running on source. exiting out of caution"
402 mexit 1
403 esac
404 fi
405 fi
406
407 # pull_reexec stops us from getting into an infinite loop if there is some
408 # kind of weird problem
409 pulla=false
410 for m in "${mountpoints[@]}"; do
411 if [[ $m == /a ]]; then
412 pulla=true
413 break
414 fi
415 done
416 if ! $pull_reexec && [[ $source ]] && $pulla ; then
417 tmpf=$(mktemp)
418 m rsync -ra $source:/usr/local/bin/{mount-latest-subvol,check-subvol-stale} /usr/local/bin
419 m rsync -ra $source:/usr/local/lib/err /usr/local/lib
420 m scp $source:/a/bin/distro-setup/btrbk-run $tmpf
421 if ! diff -q $tmpf ${BASH_SOURCE[0]}; then
422 e "found different version on host $source. reexecing"
423 install -T $tmpf /usr/local/bin/btrbk-run
424 m /usr/local/bin/btrbk-run --pull-reexec "${orig_args[@]}"
425 mexit 0
426 fi
427 fi
428
429
430 if ! command -v btrbk &>/dev/null; then
431 die "error: no btrbk binary found"
432 fi
433
434 if ! $fast; then
435 # if our mountpoints are from stale snapshots,
436 # it doesn't make sense to do a backup.
437 m check-subvol-stale ${mountpoints[@]} || die "found stale mountpoints in ${mountpoints[*]}"
438
439 # for an initial run, btrbk requires the dir to exist.
440 mkdir -p /mnt/{root,o}/btrbk
441 fi
442 local_zone=$(date +%z)
443
444 if [[ $source ]]; then
445 if $fast; then
446 zone=$local_zone
447 else
448 if ! zone=$(ssh root@$source date +%z); then
449 if $conf_only; then
450 echo "$0: warning: failed to ssh to root@$source"
451 else
452 die failed to ssh to root@$source
453 fi
454 fi
455 if [[ $zone != "$local_zone" ]]; then
456 die "error: dont confuse yourself with multiple time zones. $h has different timezone than localhost"
457 fi
458 fi
459 else
460
461 sshable=()
462 sshfail=()
463 for h in ${targets[@]}; do
464 if $fast || $conf_only; then
465 # Use some typical values in this case
466 root_size=$(( 1024 * 1024 * 2000 )) #2tb
467 percent_used=10
468 zone=$(date +%z)
469 elif remote_str=$(timeout -s 9 6 ssh root@$h "mkdir -p /mnt/root/btrbk /mnt/o/btrbk && date +%z && df --output=size,pcent / | tail -n1"); then
470 mapfile -t tmp_array <<<"$remote_str"
471 zone="${tmp_array[0]}"
472 IFS=" " read -r root_size percent_used <<<"${tmp_array[1]}"
473 percent_used=${percent_used%%%}
474
475 if (( ${#tmp_array[@]} != 2 )); then
476 die "error: didnt get 2 lines in test ssh to target $h. investigate"
477 fi
478 case $percent_used in
479 [0-9]|[1-9][0-9]) : ;;
480 *)
481 die "error: didnt get percent disk use in test ssh to target $h. investigate"
482 ;;
483 esac
484 else
485 sshfail+=($h)
486 continue
487 fi
488
489 # we may be booted into a bootstrap fs or something
490 min_root_kb=$(( 1024 * 1024 * 200 )) # 200 gb
491 if (( root_size < min_root_kb )); then
492 continue
493 fi
494
495 if (( percent_used >= 98 )); then
496 die "error: filesystem on target $h is $percent_used % full"
497 fi
498
499 # on sy, xprintidle is resetting every 12 seconds even when not
500 # idle, i dunno why, instead we are checking if the screen is locked,
501 # which is good enough.
502 #
503 # This is a separate ssh because the command can fail and thatis ok.
504 if $cron; then
505 locked=false
506 if lock_info=$(timeout -s 9 6 ssh $h DISPLAY=:0 xscreensaver-command -time); then
507 if [[ $lock_info != *non-blanked* ]]; then
508 locked=true
509 fi
510 else
511 locked=true
512 fi
513 if ! $locked; then
514 # Ignore this host. i sometimes use a non-main machine for
515 # testing or web browsing, knowing that everything will be wiped
516 # by the next backup, but I dont want it to happen as Im using
517 # it from cronjob.
518 e "warning: $h: seems to be actively in use, skipping for now"
519 continue
520 fi
521 fi
522 sshable+=($h)
523 if [[ $zone != "$local_zone" ]]; then
524 die "error: dont confuse yourself with multiple time zones. $h has different timezone than localhost"
525 fi
526 done
527 if [[ ! ${sshable[*]} ]] || { ! $cron && [[ ${sshfail[*]} ]]; }; then
528 die "failed to ssh to hosts: ${sshfail[*]}"
529 else
530 if [[ ${sshfail[*]} ]]; then
531 ret=1
532 e "error: failed to ssh to ${sshfail[*]} but continuing with other hosts"
533 fi
534 targets=(${sshable[@]})
535 fi
536 fi
537
538
539 cat >/etc/btrbk$conf_suf.conf <<EOF
540 ssh_identity /q/root/h
541 #ssh_identity /root/.ssh/home
542
543 # Just a guess that local7 is a good facility to pick.
544 # It's a bit odd that the transaction log has to be logged to
545 # a file or syslog, while other output is sent to std out.
546 # The man does not mention a way for them to be together, but
547 # I dunno if setting a log level like warn might also output
548 # transaction info.
549 transaction_syslog local7
550
551 # trying this out
552 #stream_compress zstd
553
554 # so we only run one at a time
555 lockfile /var/lock/btrbk$conf_suf.lock
556
557 # default format of short does not accomidate hourly preservation setting
558 timestamp_format long-iso
559
560 # only make a snapshot if things have changed
561 snapshot_create onchange
562 # I could make this different from target_preserve,
563 # if one disk had less space.
564 # for now, keeping them equal.
565 snapshot_preserve $std_preserve
566 snapshot_preserve_min 2h
567 snapshot_dir btrbk
568 # so, total backups = ~58
569 target_preserve $std_preserve
570 target_preserve_min 2h
571
572 # i tried this when investigating: clone no source subvolume found error
573 #incremental_prefs sro:1 srn:1 sao san:1 aro:1 arn:1
574
575 # if something fails and it's not obvious, try doing
576 # btrbk -l debug -v dryrun
577
578 rate_limit $rate_limit
579 EOF
580
581 if $incremental_strict; then
582 cat >>/etc/btrbk$conf_suf.conf <<EOF
583 incremental strict
584 EOF
585 fi
586
587 qconf() {
588 case $sub in
589 q)
590 # q has sensitive data i dont want to backup for so long
591 cat >>/etc/btrbk$conf_suf.conf <<EOF
592 snapshot_preserve $q_preserve
593 snapshot_preserve_min 2h
594 snapshot_dir btrbk
595 target_preserve $q_preserve
596 target_preserve_min 2h
597 EOF
598 ;;
599 esac
600
601 }
602
603 # make /q be last
604 mp_count=${#mountpoints[@]}
605 for (( i=0; i < mp_count - 1 ; i++ )); do
606 if [[ ${mountpoints[i]} == /q ]]; then
607 unset "mountpoints[i]"
608 mountpoints+=(/q)
609 fi
610 done
611
612 for m in ${mountpoints[@]}; do
613 case $m in
614 /o)
615 vol=/mnt/o
616 ;;
617 *)
618 vol=/mnt/root
619 ;;
620 esac
621
622 sub=${m#/}
623 if [[ $source ]]; then
624 cat >>/etc/btrbk$conf_suf.conf <<EOF
625 volume ssh://$bbksource$vol
626 subvolume $sub
627 EOF
628 qconf
629 cat >>/etc/btrbk$conf_suf.conf <<EOF
630 target send-receive $vol/btrbk
631 EOF
632 fi
633 if (( ${#targets[@]} )); then
634 cat >>/etc/btrbk$conf_suf.conf <<EOF
635 volume $vol
636 subvolume $sub
637 EOF
638 qconf
639 for tg in ${targets[@]}; do
640 # handle ipv6
641 if [[ $tg == *:* ]]; then
642 tg="[$tg]"
643 fi
644 cat >>/etc/btrbk$conf_suf.conf <<EOF
645 target send-receive ssh://$tg$vol/btrbk
646 EOF
647 done
648 fi
649 done
650
651 # todo: umount first to ensure we don't have any errors
652 # todo: do some kill fuser stuff to make umount more reliable
653
654
655 if $conf_only; then
656 mexit 0
657 fi
658
659
660
661 if $dry_run; then
662 m btrbk -c /etc/btrbk$conf_suf.conf -v -n $cmd_arg
663 mexit 0
664 fi
665 # -q and just using the syslog option seemed nice,
666 # but it doesn't show when a send has a parent and when it doesn't.
667 m btrbk -c /etc/btrbk$conf_suf.conf $preserve_arg $verbose_arg $progress_arg $cmd_arg
668
669 if $early; then
670 exit 0
671 fi
672
673 # todo: tp not valid anymore.
674 # if we have it, sync to systems which don't
675 if mountpoint $rsync_mountpoint >/dev/null; then
676 for tg in ${targets[@]}; do
677 case $tg in
678 tp)
679 dirs=(/p/c/machine_specific/tp)
680 for x in /p/c/machine_specific/*.hosts; do
681 if grep -qxF $tg $x; then
682 dirs+=(${x%.hosts})
683 fi
684 done
685 m rsync -aSAXPH --specials --devices --delete --relative ${dirs[@]} root@$tg:/
686 ;;
687 esac
688 done
689 fi
690
691 subvols=()
692 for mp in "${mountpoints[@]}"; do
693 subvols+=("${mp##*/}")
694 done
695 if [[ $source ]]; then
696 m mount-latest-subvol "${subvols[@]}"
697 else
698 for tg in ${targets[@]}; do
699 m /a/exe/mount-latest-remote "$tg" "${subvols[@]}" || ret=$?
700 done
701 fi
702
703 if [[ $ret == 0 ]]; then
704 for tg in ${targets[@]}; do
705 :
706 #ssh root@$tg /a/exe/mail-backup-clean
707 done
708 fi
709
710 mexit $ret
711
712 # todo: move variable data we don't care about backing up
713 # to /nocow and symlink it.
714
715
716 # background on btrbk timezones. with short/long, timestamps use local time.
717 # for long, if your local time moves backwards, by moving timezones or
718 # for an hour when daylight savings changes it, you will temporarily get
719 # a more aggressive retention policy for the overlapping period, and
720 # vice versa for the opposite timezone move. The alternative is using
721 # long-iso, which puts timezone info into the timestamp, which means
722 # that instead of shifting time, you shift the start of day/week/month
723 # which is used for retention to your new local time, which means for
724 # example, if you moved forward by 8 hours, the daily/weekly/monthly
725 # retention will be 8 hours more aggressive since midnight is at a new
726 # time, unless you fake the timzeone using the TZ env variable.
727 # However, in the short term, there will be no inconsistencies.
728 # I don't see any problem with shifting when the day starts for
729 # retention, so I'm using long-iso.
730
731 # note to create a long-iso timestamp: date +%Y%m%dT%H%M%S%z