-
Notifications
You must be signed in to change notification settings - Fork 0
Backup data
This repository includes a GitHub Actions workflow at .github/workflows/backup-data.yml that backs up the server-side data directory to Google Drive.
Each run:
- Connects to
deploy@45.76.134.105over SSH - Changes directory to
/var/www/fridge.dev - Compresses the
datadirectory into a zip file namedDD-MM-YY_hh-mm-ss.zip - Downloads that zip file to the GitHub Actions runner
- Uploads the zip file into a specific Google Drive folder
- Keeps only the 10 newest backup files in that folder
- Deletes the temporary zip file from both the runner and the server
Create these repository secrets in Settings -> Secrets and variables -> Actions.
This should be the same private SSH key used by the deploy workflow.
It must allow SSH access to:
deploy@45.76.134.105
This must be the Google Drive folder ID that should hold the backups.
Example Google Drive folder URL:
https://drive.google.com/drive/folders/1AbCdEfGhIjKlMnOpQrStUvWxYz
In that example, the folder ID is:
1AbCdEfGhIjKlMnOpQrStUvWxYz
This must be the full contents of an rclone.conf file containing a remote named gdrive.
Minimal example:
[gdrive]
type = drive
scope = drive
token = {"access_token":"...","token_type":"Bearer","refresh_token":"...","expiry":"2026-03-28T00:00:00.000000000Z"}
team_drive =The workflow expects the remote name to be exactly:
gdrive
On your own machine:
rclone configThen:
- Create a new remote named
gdrive - Choose
driveas the storage type - Complete the Google authentication flow
- Open the generated config file:
rclone config file- Copy the full contents into the GitHub secret named
RCLONE_CONFIG
The workflow supports:
- Manual runs via
workflow_dispatch - Scheduled runs once per day at
00:00 UTC
To run it manually:
- Open the repository on GitHub
- Go to
Actions - Select
backup data - Click
Run workflow
The remote server must have the zip command installed, because the archive is created on the server before being transferred.
The backup archive is created in:
/home/deploy
During archive creation, the workflow checks that the deploy user can read every file and read/traverse every directory under data, excluding the rebuildable data/etc/banlists/index/ cache, then prints the target archive path, backup filesystem disk usage, and the zip error log if compression fails. The generated hard-ban index is also excluded from the archive and is rebuilt automatically from the backed-up source lists after restoration.
Before creating a new archive, the workflow removes stale DD-MM-YY_hh-mm-ss.zip files from /home/deploy; the server copy is temporary, while Google Drive is the retained backup store.
The archive contains the data directory from:
/var/www/fridge.dev/data
If the workflow fails during SSH setup:
- Verify
DEPLOY_KEYis valid - Confirm the server still accepts that key for the
deployuser - Confirm the server IP in the workflow is correct
If the workflow fails during Google Drive upload:
- Verify
RCLONE_CONFIGcontains a remote namedgdrive - Verify the OAuth token in the config is still valid
- Verify
GDRIVE_BACKUP_FOLDER_IDpoints to a folder the authenticated Google account can write to
If the workflow fails on archive creation:
- Verify
/var/www/fridge.dev/dataexists on the server - Verify the
deployuser can read every file and read/traverse every directory under/var/www/fridge.dev/data - Verify
zipis installed on the server - Verify
/home/deployis writable and has enough free space for the archive
zip exit code 18 means at least one file was unreadable and skipped. To diagnose it on the server, run:
sudo -u deploy find /var/www/fridge.dev/data \
-path /var/www/fridge.dev/data/etc/banlists/index -prune -o \
\( -type f ! -readable -o -type d \( ! -readable -o ! -executable \) \) -printThe usual one-time ownership repair is to keep /data owned by the runtime user/group. Install the acl package, make deploy a member of http, and rerun a deployment; the deployment workflow then applies the current modes and inherited ACLs automatically:
sudo usermod -aG http deploy
sudo chown -R http:http /var/www/fridge.dev/data
sudo pacman -S aclAfter changing deploy group membership, start a new SSH session before rerunning the workflow.
Every deployment normalizes existing data files to shared group read/write access and installs setgid/default ACL inheritance for newly-created paths. The backup and developer-data workflows also ask the http runtime user to restore missing group read/traverse bits before copying, which remains a compatibility repair for files created before the deployment normalizer was installed. The rebuildable hard-ban index remains excluded from archive copies.