Files
2026-10-09 20:22:51 +02:00

136 lines
6.8 KiB
Plaintext

#compdef linux-backuper
# zsh completion for linux-backuper
# Generated automatically by linux-backuper completion zsh
_linux_backuper_snapshots() {
local backup_dir="/var/backups/linux-backuper"
if [[ -d "$backup_dir" ]]; then
local -a snaps
snaps=(${(@f)$(find "$backup_dir" -maxdepth 1 -name "backup_*.tar.gz" -exec basename {} .tar.gz \; 2>/dev/null)})
_describe -t snapshots 'snapshot' snaps
fi
}
_linux_backuper() {
local -a commands
commands=(
'snapshot:Capture a new system state snapshot'
'list:List existing local snapshots'
'show:Display details and metadata of a snapshot'
'diff:Compare live system against snapshot, or two snapshots'
'extract:Selectively extract a single file from a snapshot'
'restore:Restore system configuration from a snapshot'
'prune:Prune old snapshots based on retention policies'
'push:Push an existing snapshot to remote storage'
'verify:Verify snapshot cryptographic integrity'
'completion:Generate shell autocompletion script'
)
_arguments -C \
'(-v --version)'{-v,--version}'[Show version]' \
'(-h --help)'{-h,--help}'[Show help message]' \
'--json[Output machine-readable JSON to stdout]' \
'--verbose[Enable detailed diagnostic logging]' \
'1:command:->command' \
'*::arg:->args'
case "$state" in
command)
_describe -t commands 'linux-backuper commands' commands
;;
args)
case "$words[1]" in
snapshot)
_arguments \
'--profile[Backup profile]:profile:(quick system full dr)' \
'--target-dir[Destination directory]:directory:_files -/' \
'--paths[Directories or files to include]:file:_files' \
'--compression[Compression algorithm]:compression:(gzip none)' \
'--no-compression[Store plain uncompressed tar archive]' \
'--sanitize[Redact secrets and private keys for diagnostic export]' \
'--config[Path to configuration file]:file:_files' \
'--pid-path[Path to lockfile]:file:_files' \
'--keep-last[Keep N most recent snapshots]:count:' \
'--keep-daily[Keep latest snapshot for D days]:days:' \
'--keep-weekly[Keep latest snapshot for W weeks]:weeks:' \
'--keep-monthly[Keep latest snapshot for M months]:months:' \
'--push[Transfer snapshot to remote destination]:target:' \
'--ssh-key[SSH private key]:key:_files' \
'--remote-keep-last[Remote retention keep last]:count:' \
'--remote-keep-daily[Remote retention keep daily]:days:' \
'--remote-keep-weekly[Remote retention keep weekly]:weeks:' \
'--remote-keep-monthly[Remote retention keep monthly]:months:'
;;
list)
_arguments \
'--target-dir[Directory to scan]:directory:_files -/'
;;
show)
_arguments \
'1:snapshot:_linux_backuper_snapshots' \
'--packages[List all recorded installed packages]' \
'--files[List all archived file paths]' \
'--target-dir[Directory containing snapshot]:directory:_files -/'
;;
diff)
_arguments \
'1:snapshot 1:_linux_backuper_snapshots' \
'2:snapshot 2 (optional):_linux_backuper_snapshots' \
'--target-dir[Directory containing snapshots]:directory:_files -/' \
'--target-root[Filesystem root to compare against]:directory:_files -/' \
'(-u --unified)'{-u,--unified}'[Display unified diff for modified text files]'
;;
extract)
_arguments \
'1:snapshot:_linux_backuper_snapshots' \
'--file[File path inside snapshot to extract]:path:' \
'--out[Destination file or directory]:output:_files' \
'--target-dir[Directory containing snapshot]:directory:_files -/'
;;
restore)
_arguments \
'1:snapshot:_linux_backuper_snapshots' \
'--dry-run[Display execution plan without modifying filesystem]' \
'--force[Execute live restoration]' \
'--target-root[Target root directory]:directory:_files -/' \
'--include-fstab[Allow restoring /etc/fstab]' \
'--target-dir[Directory containing snapshot]:directory:_files -/' \
'--pid-path[Path to lockfile]:file:_files'
;;
prune)
_arguments \
'--keep-last[Keep N most recent snapshots]:count:' \
'--keep-daily[Keep D daily snapshots]:days:' \
'--keep-weekly[Keep W weekly snapshots]:weeks:' \
'--keep-monthly[Keep M monthly snapshots]:months:' \
'--dry-run[Simulate pruning plan]' \
'--force[Confirm deletion of pruned snapshots]' \
'--target-dir[Directory containing snapshots]:directory:_files -/'
;;
push)
_arguments \
'1:snapshot:_linux_backuper_snapshots' \
'--target[Remote destination (e.g. user@host:/path or alias)]:target:' \
'--ssh-key[SSH private key]:key:_files' \
'--remote-keep-last[Remote retention keep last]:count:' \
'--remote-keep-daily[Remote retention keep daily]:days:' \
'--remote-keep-weekly[Remote retention keep weekly]:weeks:' \
'--remote-keep-monthly[Remote retention keep monthly]:months:' \
'--target-dir[Directory containing snapshot]:directory:_files -/' \
'--config[Config path]:file:_files'
;;
verify)
_arguments \
'1:snapshot:_linux_backuper_snapshots' \
'--target-dir[Directory containing snapshot]:directory:_files -/'
;;
completion)
_arguments '1:shell:(bash zsh)'
;;
esac
;;
esac
}
_linux_backuper "$@"