This commit is contained in:
@@ -1,22 +0,0 @@
|
||||
steps:
|
||||
sanity-check: &defaults
|
||||
image: alpine
|
||||
volumes: &vols
|
||||
- "/Users/jthor/Obsidian/My Vault:/obsidian"
|
||||
- "/Volumes/What/backup:/backup"
|
||||
commands:
|
||||
- echo "Listing mount points..."
|
||||
- ls -ld /obsidian /backup
|
||||
- ls -l /backup
|
||||
when:
|
||||
event: [ push, manual, cron ]
|
||||
|
||||
backup:
|
||||
<<: *defaults
|
||||
volumes: *vols
|
||||
commands:
|
||||
- tar czf /backup/obsidian-$(date +%F).tar.gz /obsidian
|
||||
when:
|
||||
event: [ push, manual, cron ]
|
||||
cron: nightly-backup
|
||||
depends_on: [ sanity-check ]
|
||||
|
||||
22
.woodpecker.yml.original
Normal file
22
.woodpecker.yml.original
Normal file
@@ -0,0 +1,22 @@
|
||||
steps:
|
||||
sanity-check: &defaults
|
||||
image: alpine
|
||||
volumes: &vols
|
||||
- "/Users/jthor/Obsidian/My Vault:/obsidian"
|
||||
- "/Volumes/What/backup:/backup"
|
||||
commands:
|
||||
- echo "Listing mount points..."
|
||||
- ls -ld /obsidian /backup
|
||||
- ls -l /backup
|
||||
when:
|
||||
event: [ push, manual, cron ]
|
||||
|
||||
backup:
|
||||
<<: *defaults
|
||||
volumes: *vols
|
||||
commands:
|
||||
- tar czf /backup/obsidian-$(date +%F).tar.gz /obsidian
|
||||
when:
|
||||
event: [ push, manual, cron ]
|
||||
cron: nightly-backup
|
||||
depends_on: [ sanity-check ]
|
||||
26
.woodpecker/regen-update-pipeline.yml
Normal file
26
.woodpecker/regen-update-pipeline.yml
Normal file
@@ -0,0 +1,26 @@
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: regen-backup-pipeline
|
||||
|
||||
# Only run this pipeline when the manifest changes
|
||||
when:
|
||||
path:
|
||||
include:
|
||||
- backup-paths.json
|
||||
|
||||
steps:
|
||||
- name: regenerate
|
||||
image: python:3.12
|
||||
environment:
|
||||
GIT_USER_NAME: woodpecker-bot
|
||||
GIT_USER_EMAIL: ci@git.jthor.site
|
||||
GIT_AUTH_TOKEN:
|
||||
from_secret: woodpecker-bot # store your Gitea PAT or deploy key in Woodpecker secrets
|
||||
commands:
|
||||
- pip install jinja2
|
||||
- python generate_pipeline.py
|
||||
- git config user.name "$GIT_USER_NAME"
|
||||
- git config user.email "$GIT_USER_EMAIL"
|
||||
- git add .woodpecker.yml
|
||||
- git diff --cached --quiet || git commit -m "Auto-regenerate pipeline [skip ci]"
|
||||
- git push https://oauth2:$GIT_AUTH_TOKEN@git.jthor.site/jthor/ci.git HEAD:main
|
||||
4
backup-paths.json
Normal file
4
backup-paths.json
Normal file
@@ -0,0 +1,4 @@
|
||||
[{
|
||||
"path": "/Users/jthor/Obsidian",
|
||||
"name": "Obsidian"
|
||||
}]
|
||||
32
generate_pipeline.py
Normal file
32
generate_pipeline.py
Normal file
@@ -0,0 +1,32 @@
|
||||
import json
|
||||
from jinja2 import Template
|
||||
|
||||
with open("backup_manifest.json") as f:
|
||||
manifest = json.load(f)
|
||||
|
||||
template_str = """
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: backup
|
||||
|
||||
steps:
|
||||
{% for backup in backups %}
|
||||
- name: backup_{{ backup.name }}
|
||||
image: alpine:3
|
||||
volumes:
|
||||
- {{ backup.path }}:/mnt/{{ backup.name }}
|
||||
commands:
|
||||
- echo "Backing up {{ backup.path }}"
|
||||
- tar czf /tmp/{{ backup.name }}.tar.gz /mnt/{{ backup.name }}
|
||||
# Replace with your actual upload/rsync/rclone command
|
||||
- echo "Upload {{ backup.name }}.tar.gz to remote"
|
||||
{% endfor %}
|
||||
"""
|
||||
|
||||
template = Template(template_str)
|
||||
output = template.render(backups=manifest["backups"])
|
||||
|
||||
with open(".woodpecker.yml", "w") as f:
|
||||
f.write(output)
|
||||
|
||||
print("Generated .woodpecker.yml with inline volumes")
|
||||
Reference in New Issue
Block a user