Refactor to use rsync server
This commit is contained in:
+7
-8
@@ -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() {
|
||||
|
||||
+5
-6
@@ -1,17 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
readonly BUCKET="${B2_BUCKET}"
|
||||
readonly RSYNC_USER="${RSYNC_USER}"
|
||||
readonly RSYNC_SERVER="${RSYNC_SERVER}"
|
||||
|
||||
main() {
|
||||
local filepath="$1"
|
||||
local name
|
||||
name="$(basename "${filepath}")"
|
||||
|
||||
backblaze-b2 upload-file \
|
||||
--threads 2 \
|
||||
"${BUCKET}" \
|
||||
"${HOME}/timelapse/${name}" \
|
||||
"${HOSTNAME}/timelapse/${name}"
|
||||
rsync --archive --verbose \
|
||||
"${HOME}/timelapse/${name}" \
|
||||
"${RSYNC_USER}@${RSYNC_SERVER}:/timelapse/${name}"
|
||||
|
||||
# Delete outdated files.
|
||||
# This assumes the timelapse is created on an hourly basis.
|
||||
|
||||
Reference in New Issue
Block a user