Using GitHub Actions to backup OneDrive to S3

My ideals of using open-source software are fading a bit, and I’ve been using OneDrive to synchronize my files for quite some time now. It’s cheap and works reliable at least.

Until recently, I used my home server to do daily backups of all the files locally. Using a simple cron job and a simple script with Rclone.

Optimal would be to have three copies, but while having only two, I think an offsite backup in a datacenter might be a bit safer than my home.

So I created a simple GitHub Action setup to run the backup every night from OneDrive to Scaleway Glacier Cold Storage. When Scaleway Serverless Jobs are out of beta and have some options to schedule them, I might switch to them.

But so far, here’s my GitHub Actions workflow:

name: Sync OneDrive to S3

on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:

jobs:
sync:
runs-on: ubuntu-latest

steps:
- name: Sync OneDrive to S3
uses: docker://docker.io/rclone/rclone:1.65
with:
args: "sync --fast-list --checksum --update --use-server-modtime --metadata --inplace --delete-during --multi-thread-streams 10 onedrive:${{ secrets.SOURCE_DIRECTORY }} s3:${{ secrets.TARGET_DIRECTORY }}"
env:
RCLONE_CONFIG_ONEDRIVE_TYPE: onedrive
RCLONE_CONFIG_ONEDRIVE_TOKEN: ${{ secrets.ONEDRIVE_TOKEN }}
RCLONE_CONFIG_ONEDRIVE_DRIVE_ID: ${{ secrets.ONEDRIVE_DRIVE_ID }}
RCLONE_CONFIG_ONEDRIVE_DRIVE_TYPE: ${{ secrets.ONEDRIVE_DRIVE_TYPE }}
RCLONE_CONFIG_ONEDRIVE_DELTA: true
RCLONE_CONFIG_S3_TYPE: s3
RCLONE_CONFIG_S3_ENDPOINT: ${{ secrets.S3_ENDPOINT }}
RCLONE_CONFIG_S3_PROVIDER: ${{ secrets.S3_PROVIDER }}
RCLONE_CONFIG_S3_REGION: ${{ secrets.S3_REGION }}
RCLONE_CONFIG_S3_BUCKET_ACL: ${{ secrets.S3_BUCKET_ACL }}
RCLONE_CONFIG_S3_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY_ID }}
RCLONE_CONFIG_S3_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_ACCESS_KEY }}

Some notes regarding the secrets:

TARGET_DIRECTORY is the name of the S3 bucket,

SOURCE_DIRECTORY is usually empty,

and the other values are those from the Rclone configuration file (rclone config).

P.S.: After writing this post, I noticed that I did something similar when I was still using Hetzner’s Nextcloud.

Interactions & Comments