Refactor to use rsync server

This commit is contained in:
dwrz
2023-05-28 18:28:18 +00:00
parent 7501d00d76
commit 6ef6f554ce
3 changed files with 26 additions and 14 deletions
+7 -8
View File
@@ -1,8 +1,5 @@
#!/usr/bin/env bash
# Backblaze B2 Bucket
readonly BUCKET="${B2_BUCKET}"
# Devices to check -- if populated and up, no notifications are sent.
readonly DEVICES=()
@@ -19,6 +16,10 @@ readonly PROJECT="/tmp/yolov7"
# Notification recipient.
readonly RECIPIENT="${NOTIFICATION_RECIPIENT}"
# rsync user and server for backups.
readonly RSYNC_USER="${RSYNC_USER}"
readonly RSYNC_SERVER="${RSYNC_SERVER}"
acquire_lock () {
while true; do
if mkdir "${LOCKFILE}"; then
@@ -63,11 +64,9 @@ notify() {
upload() {
local name="$1"
backblaze-b2 upload-file \
--threads 2 \
"${BUCKET}" \
"${PROJECT}/motion/${name}.jpg" \
"${HOSTNAME}/photo/${name}.jpg"
rsync --archive --verbose \
"${PROJECT}/motion/${name}.jpg" \
"${RSYNC_USER}@${RSYNC_SERVER}:/photo/${name}.jpg"
}
delete_outdated() {