feat: add gitea backup timer assets
This commit is contained in:
parent
147db72330
commit
70d96d7684
@ -34,6 +34,41 @@ Cron setup details: [`scripts/VMs/HostingerVM/CRON_SETUP.md`](../scripts/VMs/Hos
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## Gitea Registry Backup
|
||||||
|
|
||||||
|
The local Gitea npm registry is backed up with a native `gitea dump` job.
|
||||||
|
|
||||||
|
Installed VM paths:
|
||||||
|
|
||||||
|
- Script: `/opt/bytelyst/scripts/backup-gitea.sh`
|
||||||
|
- Backup directory: `/opt/bytelyst/backups/gitea`
|
||||||
|
- Systemd service: `bytelyst-gitea-backup.service`
|
||||||
|
- Systemd timer: `bytelyst-gitea-backup.timer`
|
||||||
|
|
||||||
|
Versioned source files:
|
||||||
|
|
||||||
|
- [`scripts/gitea-backup.sh`](../scripts/gitea-backup.sh)
|
||||||
|
- [`systemd/bytelyst-gitea-backup.service`](../systemd/bytelyst-gitea-backup.service)
|
||||||
|
- [`systemd/bytelyst-gitea-backup.timer`](../systemd/bytelyst-gitea-backup.timer)
|
||||||
|
|
||||||
|
Useful commands:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Run a backup immediately
|
||||||
|
sudo systemctl start bytelyst-gitea-backup.service
|
||||||
|
|
||||||
|
# Check last run and next scheduled run
|
||||||
|
sudo systemctl status bytelyst-gitea-backup.service --no-pager
|
||||||
|
systemctl list-timers --all --no-pager bytelyst-gitea-backup.timer
|
||||||
|
|
||||||
|
# List retained backup dumps
|
||||||
|
ls -lh /opt/bytelyst/backups/gitea
|
||||||
|
```
|
||||||
|
|
||||||
|
The timer runs daily at `03:15 UTC` and the script deletes dumps older than 14 days by default.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## 1. Remove A Collaborator Interactively
|
## 1. Remove A Collaborator Interactively
|
||||||
|
|
||||||
Use:
|
Use:
|
||||||
|
|||||||
22
scripts/gitea-backup.sh
Executable file
22
scripts/gitea-backup.sh
Executable file
@ -0,0 +1,22 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
container="${GITEA_CONTAINER:-gitea-npm-registry}"
|
||||||
|
backup_dir="${GITEA_BACKUP_DIR:-/opt/bytelyst/backups/gitea}"
|
||||||
|
retention_days="${GITEA_BACKUP_RETENTION_DAYS:-14}"
|
||||||
|
timestamp="$(date -u +%Y%m%dT%H%M%SZ)"
|
||||||
|
name="gitea-dump-${timestamp}.zip"
|
||||||
|
container_tmp="/tmp/${name}"
|
||||||
|
host_path="${backup_dir}/${name}"
|
||||||
|
|
||||||
|
mkdir -p "$backup_dir"
|
||||||
|
|
||||||
|
docker exec --user git "$container" rm -f "$container_tmp" >/dev/null 2>&1 || true
|
||||||
|
docker exec --user git "$container" gitea dump --quiet --skip-log --file "$container_tmp"
|
||||||
|
docker cp "${container}:${container_tmp}" "$host_path"
|
||||||
|
docker exec --user git "$container" rm -f "$container_tmp" >/dev/null 2>&1 || true
|
||||||
|
|
||||||
|
chmod 600 "$host_path"
|
||||||
|
find "$backup_dir" -type f -name 'gitea-dump-*.zip' -mtime +"$retention_days" -delete
|
||||||
|
|
||||||
|
printf 'created %s\n' "$host_path"
|
||||||
8
systemd/bytelyst-gitea-backup.service
Normal file
8
systemd/bytelyst-gitea-backup.service
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=ByteLyst Gitea backup
|
||||||
|
Requires=docker.service
|
||||||
|
After=docker.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=/opt/bytelyst/scripts/backup-gitea.sh
|
||||||
10
systemd/bytelyst-gitea-backup.timer
Normal file
10
systemd/bytelyst-gitea-backup.timer
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Run ByteLyst Gitea backup daily
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnCalendar=*-*-* 03:15:00 UTC
|
||||||
|
Persistent=true
|
||||||
|
Unit=bytelyst-gitea-backup.service
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=timers.target
|
||||||
Loading…
Reference in New Issue
Block a user