Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,17 @@ jobs:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
context: .
push: true
tags: ghcr.io/buzzmoody/transfer-watcher:${{ steps.determine_tag.outputs.tag }}
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

| Variable | Description | Required | Default |
|-----------|-------------|-----------|----------|
| `SOURCE_DIR` | Local directory to monitor for changes | ✅ | — |
| `REMOTE_DEST` | Remote rsync destination (`user@host:/path`) | | |
| `REMOTE_DEST` | Remote rsync destination (`user@hostname:/data/backup`). Use an IP address if hostname lookup fails. | ✅ | — |
| `SSH_PORT` | Remote server's SSH port | | `222` |
| `BWLIMIT_KB` | Bandwidth limit in KB/s | ❌ | `9375` |
| `SYNC_INTERVAL` | Interval between sync checks (seconds) | ❌ | `10` |

Expand All @@ -29,13 +29,15 @@ services:
container_name: watcher
restart: always
environment:
- SOURCE_DIR=/data/source
- REMOTE_DEST=user@remotehost:/data/backup
- REMOTE_DEST=user@hostname:/data/backup
- SSH_PORT=222
- BWLIMIT_KB=9375
- SYNC_INTERVAL=10
volumes:
- /path/to/local/source:/data/source
- /path/to/ssh/key/id_rsa_nas_backup:/root/.ssh/id_rsa_nas_backup:ro
# the local directory you want to transfer files from
- /path/to/local/source:/transfer
# your SSH private key to the remote server
- /path/to/ssh/key/id_rsa:/root/.ssh/id_rsa:ro
```

## Install from the command line
Expand Down
10 changes: 5 additions & 5 deletions transfer_watcher.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@

set -euo pipefail

SOURCE_DIR="${SOURCE_DIR:?ERROR: SOURCE_DIR environment variable not set.}"
SOURCE_DIR="/transfer"
REMOTE_DEST="${REMOTE_DEST:?ERROR: REMOTE_DEST environment variable not set.}"

SOURCE_DIR=$(echo "$SOURCE_DIR" | sed 's/\/$//')

SSH_KEY="/root/.ssh/id_rsa_nas_backup"
SSH_PORT="222"
SSH_KEY="/root/.ssh/id_rsa"
SSH_PORT="${SSH_PORT:-222}"

BWLIMIT_KB="${BWLIMIT_KB:-9375}"
BWLIMIT_MB=$(echo "scale=0; ${BWLIMIT_KB} / 125" | bc)
Expand All @@ -33,6 +31,7 @@ check_unsynced_files() {
relative_path="${absolute_path#$SOURCE_DIR/}"
if ! grep -Fxq -- "$relative_path" "$EVENTS_FILE"; then
echo "$relative_path" >> "$EVENTS_FILE"
sort -u "$EVENTS_FILE" -o "$EVENTS_FILE"
echo "$(CURRENT_TIME) | ➕ Added unsynced file: $relative_path"
fi
done
Expand Down Expand Up @@ -104,6 +103,7 @@ while read -r absolute_path; do
relative_path="${absolute_path#$SOURCE_DIR/}"
# echo "$(CURRENT_TIME) | 🔍 Detected new file: $relative_path"
echo "$relative_path" >> "$EVENTS_FILE"
sort -u "$EVENTS_FILE" -o "$EVENTS_FILE"
fi
done &

Expand Down