simple r2 bucket uploader script that runs every 10 minutes, takes the bz2 files that are younger than 30 minutes and uploads them to the r2 bucket

This commit is contained in:
jenz 2025-02-05 20:36:10 +01:00
parent aab17ece7a
commit 6473e8e8af
4 changed files with 71 additions and 0 deletions

View File

@ -0,0 +1,8 @@
[r2demo]
type = s3
provider = Cloudflare
access_key_id =
secret_access_key =
endpoint =
acl = private

45
r2_upload/shell/r2_update.sh Executable file
View File

@ -0,0 +1,45 @@
#!/usr/bin/sh
#run full reclone when arguement is given
if [ $# -eq 1 ]
then
echo 'doing long run with all files being updated.'
#ZE server
rclone copy /home/gameservers/fastdl/css_ze/materials r2demo:/css_ze/materials/
rclone copy /home/gameservers/fastdl/css_ze/models r2demo:/css_ze/models/
rclone copy /home/gameservers/fastdl/css_ze/maps r2demo:/css_ze/maps/
rclone copy /home/gameservers/fastdl/css_ze/sound r2demo:/css_ze/sound/
#ZR server
rclone copy /home/gameservers/fastdl/css_zr/materials r2demo:/css_zr/materials/
rclone copy /home/gameservers/fastdl/css_zr/models r2demo:/css_zr/models/
rclone copy /home/gameservers/fastdl/css_zr/maps r2demo:/css_zr/maps/
rclone copy /home/gameservers/fastdl/css_zr/sound r2demo:/css_zr/sound/
#MG server
rclone copy /home/gameservers/fastdl/css_mg/materials r2demo:/css_mg/materials/
rclone copy /home/gameservers/fastdl/css_mg/models r2demo:/css_mg/models/
rclone copy /home/gameservers/fastdl/css_mg/maps r2demo:/css_mg/maps/
rclone copy /home/gameservers/fastdl/css_mg/sound r2demo:/css_mg/sound/
#svencoop
rclone copy /home/gameservers/fastdl/svencoop/svencoop_addon r2demo:svencoop/
echo 'Finished long run with all files updated.'
#else if no arguement given run default with 30minute maximum.
else
echo 'doing short run with files younger than 30 minutes.'
#ZE server
rclone copy --max-age 30m --no-traverse /home/gameservers/fastdl/css_ze/materials r2demo:/css_ze/materials/
rclone copy --max-age 30m --no-traverse /home/gameservers/fastdl/css_ze/models r2demo:/css_ze/models/
rclone copy --max-age 30m --no-traverse /home/gameservers/fastdl/css_ze/maps r2demo:/css_ze/maps/
rclone copy --max-age 30m --no-traverse /home/gameservers/fastdl/css_ze/sound r2demo:/css_ze/sound/
#ZR server
rclone copy --max-age 30m --no-traverse /home/gameservers/fastdl/css_zr/materials r2demo:/css_zr/materials/
rclone copy --max-age 30m --no-traverse /home/gameservers/fastdl/css_zr/models r2demo:/css_zr/models/
rclone copy --max-age 30m --no-traverse /home/gameservers/fastdl/css_zr/maps r2demo:/css_zr/maps/
rclone copy --max-age 30m --no-traverse /home/gameservers/fastdl/css_zr/sound r2demo:/css_zr/sound/
#MG server
rclone copy --max-age 30m --no-traverse /home/gameservers/fastdl/css_mg/materials r2demo:/css_mg/materials/
rclone copy --max-age 30m --no-traverse /home/gameservers/fastdl/css_mg/models r2demo:/css_mg/models/
rclone copy --max-age 30m --no-traverse /home/gameservers/fastdl/css_mg/maps r2demo:/css_mg/maps/
rclone copy --max-age 30m --no-traverse /home/gameservers/fastdl/css_mg/sound r2demo:/css_mg/sound/
#svencoop
rclone copy --max-age 30m --no-traverse /home/gameservers/fastdl/svencoop/svencoop_addon r2demo:svencoop/
echo 'Finished short run with files younger than 30 minutes.'
fi

View File

@ -0,0 +1,9 @@
[Unit]
Description=Rclones to R2 bucket every 10 minutes
[Service]
Type=simple
User=gameservers
Group=gameservers
WorkingDirectory=/home/gameservers/fastdl_sync
ExecStart=/home/gameservers/fastdl_sync/r2_update.sh

View File

@ -0,0 +1,9 @@
[Unit]
Description=rclones new content every 10 minutes
Requires=r2_bucket_rclone.service
[Timer]
OnCalendar=*-*-* *:0,10,20,30,40,50
[Install]
WantedBy=multi-user.target