init commit

This commit is contained in:
t0is 2025-03-03 16:31:21 +01:00
commit 6d4950d5df
4 changed files with 68 additions and 0 deletions

15
Dockerfile Normal file
View File

@ -0,0 +1,15 @@
FROM alpine:latest
# Install rclone and bash
RUN apk update && apk add --no-cache rclone bash
WORKDIR /app
# Copy the entrypoint script into the container
COPY entrypoint.sh .
# Make sure the script is executable
RUN chmod +x entrypoint.sh
CMD ["./entrypoint.sh"]

11
docker-compose.yml Normal file
View File

@ -0,0 +1,11 @@
services:
drive-sync:
build: .
environment:
# Set your target Google Drive folder ID here.
- DRIVE_FOLDER_ID=1HKPydId23FmOWaT5dzBnDt0ooIMwzDLS
volumes:
# Map your local folder to the container's /shared/transcriptor/clips
- /shared/transcriptor/clips:/shared/transcriptor/clips
# Mount your rclone configuration file containing the Google Drive remote details.
- ./rclone.conf:/root/.config/rclone/rclone.conf:ro

35
entrypoint.sh Normal file
View File

@ -0,0 +1,35 @@
#!/bin/bash
# This script uses rclone to copy new and updated files from the mounted folder to Google Drive,
# preserving the directory structure, and then deletes local files that are over 3 days old.
# Check that DRIVE_FOLDER_ID environment variable is set.
if [ -z "$DRIVE_FOLDER_ID" ]; then
echo "DRIVE_FOLDER_ID environment variable is not set. Exiting."
exit 1
fi
# The local folder to be synced (mapped from the host)
LOCAL_DIR="/shared/transcriptor/clips"
# The remote name must match the one defined in your rclone config (e.g., "gdrive")
REMOTE_NAME="gdrive"
# Continuous loop to perform the sync every 60 seconds.
while true; do
echo "Starting sync: $(date)"
# The rclone copy command will:
# - Copy new or updated files (with --update, only files with newer timestamps are overwritten)
# - Preserve the folder structure by default
# - Use the provided Google Drive folder ID via --drive-folder-id
rclone copy "$LOCAL_DIR" "${REMOTE_NAME}:" \
--drive-folder-id="${DRIVE_FOLDER_ID}" \
--update \
--verbose
echo "Sync complete: $(date)"
echo "Deleting local files older than 3 days: $(date)"
# Delete files in LOCAL_DIR (and its subdirectories) that are over 3 days old
find "$LOCAL_DIR" -type f -mtime +3 -delete
sleep 600
done

7
rclone.conf Normal file
View File

@ -0,0 +1,7 @@
[gdrive]
type = drive
client_id = 830644885820-9792hiic15cmglcbjg5nl210im3m7m6r.apps.googleusercontent.com
client_secret = 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
scope = drive
token = {"access_token":"ya29.a0AeXRPp5InawrsmE5ZZxff0Z4nYmQZJggOxhkHmT_YMe4tpwDaVMhYaYdKI4C5nWkvaMSPCTxQCawoo6-6ZnEMqS9MApZUyKlSbt2GS_3QEtwZtmDX5nlwTBhDuXpAWBdKmSV_BxY_-GU921RjyPRnca6A3mv9Zcuojdvk6PraCgYKAesSARMSFQHGX2Miwm4Sp1WgzBVkMEmzqTDUZw0175","token_type":"Bearer","refresh_token":"1//09jwQv3qxecZtCgYIARAAGAkSNwF-L9Ir1gOqVz6-Xf9odzOxDgQdUQfD-_N2e_0WOYKKSSUUsIr9k5jey9d_EZrxNveLK7u-YQE","expiry":"2025-03-03T17:24:59.513329+01:00"}
team_drive =