WebDAV Sync
Overview
Run scripts/webdav_sync.py to package local content as .tar or .tar.gz and upload it to a WebDAV target defined in an env file. Prefer this skill for repeatable backups and scheduled sync tasks.
Core Logic
- Read WebDAV credentials from an env file using
WEBDAV_SITE,WEBDAV_USERID, andWEBDAV_PWD. - Create archives with explicit exclude patterns instead of implicit ignores.
- Prefer explicit paths in cron jobs and wrappers.
- Keep notification delivery outside the archive payload. Use the host messaging path after upload success or failure.
- When changing sync scope, update both the wrapper script and any scheduled job that invokes it.
- Record every confirmed improvement or compatibility fix in
maintenance.log.
Execution Patterns
Direct run
python3 {baseDir}/scripts/webdav_sync.py \
--source /path/to/folder \
--archive-prefix backup \
--remote-subdir backups \
--notify-channel <channel> \
--notify-target <target> \
--exclude 'folder/.trash' \
--exclude 'folder/.trash/*' \
--exclude 'folder/tmp' \
--exclude 'folder/tmp/*'
Wrapper usage
Keep stable wrappers in a project-level scripts directory for cron or one-command execution. Use a thin wrapper that pins the interpreter and passes host-specific paths as arguments.
Guardrails
- Keep the script stdlib-only except for external binaries already present on the host (
curl, optional messaging CLI). - Do not print credentials.
- Do not pass WebDAV credentials through command-line arguments; use a temporary credential file with
0600permissions and delete it after the request finishes. - Accept WebDAV
MKCOLresponses201,301, and405as non-fatal directory-ready states. - Accept upload responses
200,201, and204as success. - If the user asks for pure
.tar, set--compression none; otherwise prefergz. - For future sync targets, add explicit exclude patterns instead of broad hidden-file stripping.
Resources
- Read
references/operations.mdfor env keys, wrapper layout, and scheduling notes. - Run
scripts/webdav_sync.py --helpfor the CLI surface.