2017-11-04 15:54:21 +00:00
|
|
|
|
#compdef borg
|
|
|
|
|
|
|
|
|
|
# -------
|
|
|
|
|
#
|
|
|
|
|
# To Install:
|
|
|
|
|
#
|
2019-02-10 19:27:04 +00:00
|
|
|
|
# Copy this file to /usr/[local]/share/zsh/site-functions/
|
2017-11-04 15:54:21 +00:00
|
|
|
|
#
|
|
|
|
|
# -------
|
|
|
|
|
# borgbackup ZSH completion
|
|
|
|
|
# Kevin Gravier 2017 <kevin@mrkmg.com>
|
2019-02-10 19:27:04 +00:00
|
|
|
|
#
|
2017-11-04 15:54:21 +00:00
|
|
|
|
# The MIT License (MIT)
|
|
|
|
|
|
|
|
|
|
# Copyright (c) 2017 Kevin
|
|
|
|
|
|
|
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
|
# of this software and associated documentation files (the "Software"), to deal
|
|
|
|
|
# in the Software without restriction, including without limitation the rights
|
|
|
|
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
|
# copies of the Software, and to permit persons to whom the Software is
|
|
|
|
|
# furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
|
|
# The above copyright notice and this permission notice shall be included in all
|
|
|
|
|
# copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
|
# SOFTWARE.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_borg() {
|
|
|
|
|
typeset -A opt_args
|
2018-01-10 21:32:22 +00:00
|
|
|
|
local -a borg_possible_commands borg_possible_key_commands commands keyCommands borg_common_options
|
2017-11-04 15:54:21 +00:00
|
|
|
|
local command keyCommand item subItem
|
|
|
|
|
|
2018-01-10 21:32:22 +00:00
|
|
|
|
borg_common_options=({-h,--help}'[show this help message and exit]'
|
2017-11-04 15:54:21 +00:00
|
|
|
|
--critical'[work on log level CRITICAL]'
|
|
|
|
|
--error'[work on log level ERROR]'
|
|
|
|
|
--warning'[work on log level WARNING (default)]'
|
|
|
|
|
{--info,-v,--verbose}'[work on log level INFO]'
|
|
|
|
|
--debug'[work on log level DEBUG]'
|
|
|
|
|
--default-topic'[enable TOPIC debugging (can be specified multiple times).]:TOPIC'
|
|
|
|
|
{-p,--progress}'[show progress information]'
|
|
|
|
|
--log-json'[Output one JSON object per log line instead of formatted text.]'
|
|
|
|
|
--lock-wait'[wait at most SECONDS for acquiring a repository/cache lock (default: 1).]:SECONDS'
|
|
|
|
|
--show-version'[show/log the borg version]'
|
|
|
|
|
--show-rc'[show/log the return code (rc)]'
|
|
|
|
|
--umask'[set umask to M (local and remote, default: 0077)]:umask'
|
|
|
|
|
--remote-path'[set remote path to executable (default: "borg")]:_files'
|
|
|
|
|
--remote-ratelimit'[set remote network upload rate limit in kiByte/s (default: 0=unlimited)]:RATE'
|
|
|
|
|
--consider-part-files'[treat part files like normal files (e.g. to list/extract them)]'
|
2019-02-08 13:27:14 +00:00
|
|
|
|
--debug-profile'[write execution profile in Borg format into FILE.]:_files'
|
|
|
|
|
--rsh'[use COMMAND instead of ssh]:COMMAND')
|
2017-11-04 15:54:21 +00:00
|
|
|
|
|
2019-02-08 15:44:36 +00:00
|
|
|
|
borg_possible_commands=(init create extract check rename list diff delete prune compact info mount umount key upgrade recreate export-tar serve config with-lock break-lock benchmark help)
|
2017-11-04 15:54:21 +00:00
|
|
|
|
borg_possible_key_commands=(change-passphrase import export)
|
|
|
|
|
command=""
|
|
|
|
|
keyCommand=""
|
|
|
|
|
|
|
|
|
|
for item in $words; do
|
|
|
|
|
(( ${borg_possible_commands[(I)$item]} )) && command=$item
|
|
|
|
|
(( ${borg_possible_key_commands[(I)$item]} )) && keyCommand=$item
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
case $command in
|
|
|
|
|
(init)
|
|
|
|
|
_arguments \
|
|
|
|
|
'2:repo:_files'\
|
2019-02-10 19:27:04 +00:00
|
|
|
|
{-e,--encryption}'[select encryption key mode]:mode:(none keyfile keyfile-blake2 repokey repokey-blake2 authenticated authenticated-blake2)'\
|
2017-11-04 15:54:21 +00:00
|
|
|
|
--append-only'[only allow appending to repository segment files]'\
|
|
|
|
|
--storage-quota'[Override storage quota of the repository]:QUOTA'\
|
2019-02-08 13:27:14 +00:00
|
|
|
|
--make-parent-dirs'[create parent directories]'\
|
2018-01-10 21:32:22 +00:00
|
|
|
|
$borg_common_options
|
2017-11-04 15:54:21 +00:00
|
|
|
|
;;
|
|
|
|
|
(create)
|
|
|
|
|
_arguments \
|
|
|
|
|
'2:archives:__borg_archive'\
|
|
|
|
|
'3:path:_files'\
|
|
|
|
|
{-n,--dry-run}'[do not create a backup archive]'\
|
|
|
|
|
{-s,--stats}'[print statistics for the created archive]'\
|
|
|
|
|
--list'[output verbose list of items (files, dirs, ...)]'\
|
|
|
|
|
--filter'[only display items with the given status characters]:STATUSCHARS'\
|
|
|
|
|
--json'[output stats as JSON. Implies --stats.]'\
|
|
|
|
|
--no-cache-sync'[experimental: do not synchronize the cache. Implies not using the files cache.]'\
|
2018-06-22 21:53:44 +00:00
|
|
|
|
--stdin-name'[use NAME in archive for stdin data]:NAME'\
|
2017-11-04 15:54:21 +00:00
|
|
|
|
{-e,--exclude}'[exclude paths matching PATTERN]:PATTERN'\
|
|
|
|
|
--exclude-from'[read exclude patterns from EXCLUDEFILE, one per line]:_files'\
|
|
|
|
|
--pattern'[experimental: include/exclude paths matching PATTERN]:PATTERN'\
|
|
|
|
|
--patterns-from'[experimental: read include/exclude patterns from PATTERNFILE, one per line]:_files'\
|
|
|
|
|
--exclude-caches'[exclude directories that contain a CACHEDIR.TAG file ]'\
|
|
|
|
|
--exclude-if-present'[exclude directories that are tagged by containing a filesystem object with the given NAME]:NAME'\
|
2019-03-15 16:52:51 +00:00
|
|
|
|
--keep-exclude-tags'[if tag objects are specified with --exclude-if-present, don’t omit the tag objects themselves]'\
|
2018-01-10 21:32:22 +00:00
|
|
|
|
{-x,--one-file-system}'[stay in the same file system ]'\
|
|
|
|
|
--numeric-owner'[only store numeric user and group identifiers]'\
|
|
|
|
|
--noatime'[do not store atime into archive]'\
|
|
|
|
|
--nobirthtime'[do not store birthtime (creation date) into archive]'\
|
|
|
|
|
--nobsdflags'[do not read and store bsdflags (e.g. NODUMP, IMMUTABLE) into archive]'\
|
2020-03-18 20:39:48 +00:00
|
|
|
|
--noflags'[do not read and store flags (e.g. NODUMP, IMMUTABLE) into archive]'\
|
2019-02-10 19:27:04 +00:00
|
|
|
|
--files-cache'[operate files cache in MODE. default: ctime,size,inode]:mode:(ctime,size,inode mtime,size,inode ctime,size mtime,size rechunk,ctime rechunk,mtime disabled)'\
|
2018-01-10 21:32:22 +00:00
|
|
|
|
--read-special'[open and read block and char device files as well as FIFOs as if they were regular files.]'\
|
2017-11-04 15:54:21 +00:00
|
|
|
|
--comment'[add a comment text to the archive]:COMMENT'\
|
|
|
|
|
--timestamp'[manually specify the archive creation date/time]:TIMESTAMP'\
|
2018-01-10 21:32:22 +00:00
|
|
|
|
--timestamp'[manually specify the archive creation date/time by a reference file/directory]:_files'\
|
2017-11-04 15:54:21 +00:00
|
|
|
|
{-c,--checkpoint-interval}'[write checkpoint every SECONDS seconds]:SECONDS'\
|
2018-01-10 21:32:22 +00:00
|
|
|
|
--chunker-params'[specify the chunker parameters]:PARAMS'\
|
2017-11-04 15:54:21 +00:00
|
|
|
|
{-C,--compression}'[select compression algorithm]:COMPRESSION'\
|
2018-01-10 21:32:22 +00:00
|
|
|
|
$borg_common_options
|
2017-11-04 15:54:21 +00:00
|
|
|
|
;;
|
|
|
|
|
(extract)
|
|
|
|
|
_arguments \
|
|
|
|
|
'2:archives:__borg_archive'\
|
|
|
|
|
'3:path:_files'\
|
|
|
|
|
--list'[output verbose list of items (files, dirs, ...)]'\
|
|
|
|
|
{-n,--dry-run}'[do not actually change any files]'\
|
|
|
|
|
--numeric-owner'[only obey numeric user and group identifiers]'\
|
|
|
|
|
--nobsdflags'[do not extract/set bsdflags (e.g. NODUMP, IMMUTABLE)]'\
|
2020-03-18 20:39:48 +00:00
|
|
|
|
--noflags'[do not extract/set flags (e.g. NODUMP, IMMUTABLE)]'\
|
2017-11-04 15:54:21 +00:00
|
|
|
|
--stdout'[write all extracted data to stdout]'\
|
|
|
|
|
--sparse'[create holes in output sparse file from all-zero chunks]'\
|
|
|
|
|
{-e,--exclude}'[exclude paths matching PATTERN]:PATTERN'\
|
|
|
|
|
--exclude-from'[read exclude patterns from EXCLUDEFILE, one per line]:_files'\
|
|
|
|
|
--pattern'[experimental: include/exclude paths matching PATTERN]:PATTERN'\
|
|
|
|
|
--patterns-from'[experimental: read include/exclude patterns from PATTERNFILE, one per line]:_files'\
|
|
|
|
|
--strip-components'[Remove the specified number of leading path elements. Paths with fewer elements will be silently skipped.]:NUMBER'\
|
2018-01-10 21:32:22 +00:00
|
|
|
|
$borg_common_options
|
2017-11-04 15:54:21 +00:00
|
|
|
|
;;
|
2018-01-10 21:32:22 +00:00
|
|
|
|
(check)
|
2017-11-04 15:54:21 +00:00
|
|
|
|
_arguments \
|
|
|
|
|
'2:archives:__borg_archive'\
|
2018-01-10 21:32:22 +00:00
|
|
|
|
--repository-only'[only perform repository checks]'\
|
|
|
|
|
--archives-only'[only perform archives checks]'\
|
|
|
|
|
--verify-data'[perform cryptographic archive data integrity verification]'\
|
|
|
|
|
--repair'[attempt to repair any inconsistencies found]'\
|
|
|
|
|
--save-space'[work slower, but using less space]'\
|
2019-03-15 16:52:51 +00:00
|
|
|
|
--max-duration'[partial repo check for max. SECONDS]:SECONDS'\
|
2018-01-10 21:32:22 +00:00
|
|
|
|
{-P,--prefix}'[only consider archive names starting with this prefix.]:PREFIX'\
|
|
|
|
|
{-a,--glob-archives}'[only consider archive names matching the glob]:GLOB'\
|
2019-02-10 19:27:04 +00:00
|
|
|
|
--sort-by'[Comma-separated list of sorting keys]:keys:(timestamp name id)'\
|
2018-01-10 21:32:22 +00:00
|
|
|
|
--first'[consider first N archives after other filters were applied]:N'\
|
|
|
|
|
--last'[consider last N archives after other filters were applied]:N'\
|
|
|
|
|
$borg_common_options
|
|
|
|
|
;;
|
|
|
|
|
(rename)
|
|
|
|
|
_arguments \
|
|
|
|
|
'2:archives:__borg_archive'\
|
|
|
|
|
'3:name:NAME'\
|
|
|
|
|
$borg_common_options
|
|
|
|
|
;;
|
|
|
|
|
(list)
|
|
|
|
|
_arguments \
|
|
|
|
|
'2:archives:__borg_archive'\
|
|
|
|
|
'*:path:_files'\
|
|
|
|
|
--short'[only print file/directory names, nothing else]'\
|
2019-03-15 16:52:51 +00:00
|
|
|
|
--format'[specify format for file listing]:FORMAT'\
|
2018-01-10 21:32:22 +00:00
|
|
|
|
--json'[Only valid for listing repository contents. Format output as JSON.]'\
|
|
|
|
|
--json-lines'[Only valid for listing archive contents. Format output as JSON Lines. ]'\
|
|
|
|
|
{-P,--prefix}'[only consider archive names starting with this prefix.]:PREFIX'\
|
|
|
|
|
{-a,--glob-archives}'[only consider archive names matching the glob]:GLOB'\
|
2019-02-10 19:27:04 +00:00
|
|
|
|
--sort-by'[Comma-separated list of sorting keys]:keys:(timestamp name id)'\
|
2018-01-10 21:32:22 +00:00
|
|
|
|
--first'[consider first N archives after other filters were applied]:N'\
|
|
|
|
|
--last'[consider last N archives after other filters were applied]:N'\
|
2017-11-04 15:54:21 +00:00
|
|
|
|
{-e,--exclude}'[exclude paths matching PATTERN]:PATTERN'\
|
|
|
|
|
--exclude-from'[read exclude patterns from EXCLUDEFILE, one per line]:_files'\
|
|
|
|
|
--pattern'[experimental: include/exclude paths matching PATTERN]:PATTERN'\
|
|
|
|
|
--patterns-from'[experimental: read include/exclude patterns from PATTERNFILE, one per line]:_files'\
|
2018-01-10 21:32:22 +00:00
|
|
|
|
$borg_common_options
|
2017-11-04 15:54:21 +00:00
|
|
|
|
;;
|
|
|
|
|
(diff)
|
|
|
|
|
_arguments \
|
|
|
|
|
'2:archives:__borg_archive'\
|
2019-03-15 16:40:47 +00:00
|
|
|
|
'3:archives:__borg_archive2'\
|
2017-11-04 15:54:21 +00:00
|
|
|
|
'*:path:_files'\
|
|
|
|
|
--numeric-owner'[only obey numeric user and group identifiers]'\
|
2018-01-10 21:32:22 +00:00
|
|
|
|
--same-chunker-params'[override check of chunker parameters.]'\
|
|
|
|
|
--sort'[sort the output lines by file path.]'\
|
2017-11-04 15:54:21 +00:00
|
|
|
|
{-e,--exclude}'[exclude paths matching PATTERN]:PATTERN'\
|
|
|
|
|
--exclude-from'[read exclude patterns from EXCLUDEFILE, one per line]:_files'\
|
|
|
|
|
--pattern'[experimental: include/exclude paths matching PATTERN]:PATTERN'\
|
|
|
|
|
--patterns-from'[experimental: read include/exclude patterns from PATTERNFILE, one per line]:_files'\
|
2018-01-10 21:32:22 +00:00
|
|
|
|
$borg_common_options
|
2017-11-04 15:54:21 +00:00
|
|
|
|
|
|
|
|
|
;;
|
|
|
|
|
(delete)
|
|
|
|
|
_arguments \
|
|
|
|
|
'2:archives:__borg_archive'\
|
|
|
|
|
'*:archives:archives'\
|
2018-06-22 21:53:44 +00:00
|
|
|
|
--dry-run'[do not change the repository]'\
|
2017-11-04 15:54:21 +00:00
|
|
|
|
{-s,--stats}'[print statistics for the deleted archive]'\
|
|
|
|
|
--cache-only'[delete only the local cache for the given repository]'\
|
|
|
|
|
--force'[force deletion of corrupted archives, use --force --force in case --force does not work.]'\
|
|
|
|
|
--save-space'[work slower, but using less space]'\
|
|
|
|
|
{-P,--prefix}'[only consider archive names starting with this prefix.]:PREFIX'\
|
|
|
|
|
{-a,--glob-archives}'[only consider archive names matching the glob]:GLOB'\
|
2019-02-10 19:27:04 +00:00
|
|
|
|
--sort-by'[Comma-separated list of sorting keys]:keys:(timestamp name id)'\
|
2017-11-04 15:54:21 +00:00
|
|
|
|
--first'[consider first N archives after other filters were applied]:N'\
|
|
|
|
|
--last'[consider last N archives after other filters were applied]:N'\
|
2018-01-10 21:32:22 +00:00
|
|
|
|
$borg_common_options
|
2017-11-04 15:54:21 +00:00
|
|
|
|
;;
|
2018-01-10 21:32:22 +00:00
|
|
|
|
(prune)
|
2017-11-04 15:54:21 +00:00
|
|
|
|
_arguments \
|
|
|
|
|
'2:archives:__borg_archive'\
|
2018-01-10 21:32:22 +00:00
|
|
|
|
{-n,--dry-run}'[do not change repository]'\
|
|
|
|
|
--force'[force pruning of corrupted archives]'\
|
|
|
|
|
{-s,--stats}'[print statistics for the deleted archive]'\
|
|
|
|
|
--list'[output verbose list of archives it keeps/prunes]'\
|
|
|
|
|
--keep-within'[keep all archives within this time interval]:INTERVAL'\
|
|
|
|
|
{--keep-last,--keep-secondly}'[number of secondly archives to keep]:N'\
|
|
|
|
|
--keep-minutely'[number of minutely archives to keep]:N'\
|
|
|
|
|
{-H,--keep-hourly}'[number of hourly archives to keep]:N'\
|
|
|
|
|
{-d,--keep-daily}'[number of daily archives to keep]:N'\
|
|
|
|
|
{-w,--keep-weekly}'[number of weekly archives to keep]:N'\
|
|
|
|
|
{-m,--keep-monthly}'[number of monthly archives to keep]:N'\
|
|
|
|
|
{-y,--keep-yearly}'[number of yearly archives to keep]:N'\
|
|
|
|
|
--save-space'[work slower, but using less space]'\
|
2017-11-04 15:54:21 +00:00
|
|
|
|
{-P,--prefix}'[only consider archive names starting with this prefix.]:PREFIX'\
|
|
|
|
|
{-a,--glob-archives}'[only consider archive names matching the glob]:GLOB'\
|
2018-01-10 21:32:22 +00:00
|
|
|
|
$borg_common_options
|
|
|
|
|
;;
|
2019-02-08 15:44:36 +00:00
|
|
|
|
(compact)
|
|
|
|
|
_arguments \
|
|
|
|
|
'2:archives:__borg_archive'\
|
|
|
|
|
--cleanup-commits'[cleanup commit-only 17-byte segment files]'\
|
|
|
|
|
$borg_common_options
|
|
|
|
|
;;
|
2018-01-10 21:32:22 +00:00
|
|
|
|
(info)
|
|
|
|
|
_arguments \
|
|
|
|
|
'2:archives:__borg_archive'\
|
|
|
|
|
--json'[format output as JSON]'\
|
|
|
|
|
{-P,--prefix}'[only consider archive names starting with this prefix.]:PREFIX'\
|
|
|
|
|
{-a,--glob-archives}'[only consider archive names matching the glob]:GLOB'\
|
2019-02-10 19:27:04 +00:00
|
|
|
|
--sort-by'[Comma-separated list of sorting keys]:keys:(timestamp name id)'\
|
2017-11-04 15:54:21 +00:00
|
|
|
|
--first'[consider first N archives after other filters were applied]:N'\
|
|
|
|
|
--last'[consider last N archives after other filters were applied]:N'\
|
2018-01-10 21:32:22 +00:00
|
|
|
|
$borg_common_options
|
2017-11-04 15:54:21 +00:00
|
|
|
|
;;
|
|
|
|
|
(mount)
|
|
|
|
|
_arguments \
|
|
|
|
|
'2:archives:__borg_archive'\
|
|
|
|
|
'3:mountpoint:_files'\
|
|
|
|
|
{-f,--foreground}'[stay in foreground, do not daemonize]'\
|
2019-02-10 19:27:04 +00:00
|
|
|
|
-o'[Extra mount options]:options:(ac_attr_timeout= allow_damaged_files allow_other allow_root attr_timeout= auto auto_cache auto_unmount default_permissions entry_timeout= gid= group_id= kernel_cache max_read= negative_timeout= noauto noforget remember= remount rootmode= uid= umask= user user_id= versions)'\
|
2017-11-04 15:54:21 +00:00
|
|
|
|
{-P,--prefix}'[only consider archive names starting with this prefix.]:PREFIX'\
|
|
|
|
|
{-a,--glob-archives}'[only consider archive names matching the glob]:GLOB'\
|
2019-02-10 19:27:04 +00:00
|
|
|
|
--sort-by'[Comma-separated list of sorting keys]:keys:(timestamp name id)'\
|
2017-11-04 15:54:21 +00:00
|
|
|
|
--first'[consider first N archives after other filters were applied]:N'\
|
|
|
|
|
--last'[consider last N archives after other filters were applied]:N'\
|
2018-06-22 21:53:44 +00:00
|
|
|
|
{-e,--exclude}'[exclude paths matching PATTERN]:PATTERN'\
|
|
|
|
|
--exclude-from'[read exclude patterns from EXCLUDEFILE, one per line]:_files'\
|
|
|
|
|
--pattern'[experimental: include/exclude paths matching PATTERN]:PATTERN'\
|
|
|
|
|
--patterns-from'[experimental: read include/exclude patterns from PATTERNFILE, one per line]:_files'\
|
|
|
|
|
--strip-components'[Remove the specified number of leading path elements. Paths with fewer elements will be silently skipped.]:NUMBER'\
|
2018-01-10 21:32:22 +00:00
|
|
|
|
$borg_common_options
|
2017-11-04 15:54:21 +00:00
|
|
|
|
;;
|
|
|
|
|
(umount)
|
|
|
|
|
_arguments \
|
|
|
|
|
'2:mountpoint:_files'\
|
2018-01-10 21:32:22 +00:00
|
|
|
|
$borg_common_options
|
2017-11-04 15:54:21 +00:00
|
|
|
|
;;
|
2018-01-10 21:32:22 +00:00
|
|
|
|
(key)
|
|
|
|
|
case $keyCommand in
|
|
|
|
|
(change-passphrase)
|
|
|
|
|
_arguments \
|
|
|
|
|
'2:subCommand:(change-passphrase import export)'\
|
|
|
|
|
'3:archives:__borg_archive'\
|
|
|
|
|
$borg_common_options
|
|
|
|
|
;;
|
|
|
|
|
(export)
|
|
|
|
|
_arguments \
|
|
|
|
|
'2:subCommand:(change-passphrase import export)'\
|
|
|
|
|
'3:archives:__borg_archive'\
|
|
|
|
|
'4:path:_files'\
|
|
|
|
|
--paper'[Create an export suitable for printing and later type-in]'\
|
|
|
|
|
--qr-html'[Create an html file suitable for printing and later type-in or qr scan]'\
|
|
|
|
|
$borg_common_options
|
|
|
|
|
;;
|
|
|
|
|
(import)
|
|
|
|
|
_arguments \
|
|
|
|
|
'2:subCommand:(change-passphrase import export)'\
|
|
|
|
|
'3:archives:__borg_archive'\
|
|
|
|
|
'4:path:_files'\
|
|
|
|
|
--paper'[interactively import from a backup done with --paper]'\
|
|
|
|
|
$borg_common_options
|
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
_arguments \
|
|
|
|
|
'2:subCommand:(change-passphrase import export)'\
|
|
|
|
|
$borg_common_options
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
;;
|
|
|
|
|
(upgrade)
|
2017-11-04 15:54:21 +00:00
|
|
|
|
_arguments \
|
|
|
|
|
'2:archives:__borg_archive'\
|
2018-01-10 21:32:22 +00:00
|
|
|
|
{-n,--dry-run}'[do not change repository]'\
|
|
|
|
|
--inplace'[rewrite repository in place, with no chance of going back to older versions of the repository.]'\
|
|
|
|
|
--force'[Force upgrade]'\
|
|
|
|
|
--tam'[Enable manifest authentication (in key and cache).]'\
|
|
|
|
|
--disable-tam'[Disable manifest authentication (in key and cache).]'\
|
|
|
|
|
$borg_common_options
|
2017-11-04 15:54:21 +00:00
|
|
|
|
;;
|
2018-01-10 21:32:22 +00:00
|
|
|
|
(recreate)
|
2017-11-04 15:54:21 +00:00
|
|
|
|
_arguments \
|
|
|
|
|
'2:archives:__borg_archive'\
|
2018-01-10 21:32:22 +00:00
|
|
|
|
'3:path:_files'\
|
|
|
|
|
--list'[output verbose list of items (files, dirs, ...)]'\
|
|
|
|
|
--filter'[only display items with the given status characters]:STATUSCHARS'\
|
|
|
|
|
{-n,--dry-run}'[do not create a backup archive]'\
|
|
|
|
|
{-s,--stats}'[print statistics at end]'\
|
|
|
|
|
{-e,--exclude}'[exclude paths matching PATTERN]:PATTERN'\
|
|
|
|
|
--exclude-from'[read exclude patterns from EXCLUDEFILE, one per line]:_files'\
|
|
|
|
|
--pattern'[experimental: include/exclude paths matching PATTERN]:PATTERN'\
|
|
|
|
|
--patterns-from'[experimental: read include/exclude patterns from PATTERNFILE, one per line]:_files'\
|
|
|
|
|
--exclude-caches'[exclude directories that contain a CACHEDIR.TAG file ]'\
|
|
|
|
|
--exclude-if-present'[exclude directories that are tagged by containing a filesystem object with the given NAME]:NAME'\
|
2019-03-15 16:52:51 +00:00
|
|
|
|
--keep-exclude-tags'[if tag objects are specified with --exclude-if-present, don’t omit the tag objects themselves]'\
|
2018-01-10 21:32:22 +00:00
|
|
|
|
--target'[create a new archive with the name ARCHIVE]:ARCHIVE'\
|
|
|
|
|
{-c,--checkpoint-interval}'[write checkpoint every SECONDS seconds]:SECONDS'\
|
|
|
|
|
--comment'[add a comment text to the archive]:COMMENT'\
|
|
|
|
|
--timestamp'[manually specify the archive creation date/time]:TIMESTAMP'\
|
|
|
|
|
{-C,--compression}'[select compression algorithm]:COMPRESSION'\
|
2019-02-10 19:27:04 +00:00
|
|
|
|
--recompress'[recompress data chunks according to --compression if if-different]:params:(if-different always)'\
|
2018-01-10 21:32:22 +00:00
|
|
|
|
--chunker-params'[pecify the chunker parameters]:PARAMS'\
|
|
|
|
|
$borg_common_options
|
2017-11-04 15:54:21 +00:00
|
|
|
|
;;
|
2018-01-10 21:32:22 +00:00
|
|
|
|
(export-tar)
|
2017-11-04 15:54:21 +00:00
|
|
|
|
_arguments \
|
|
|
|
|
'2:archives:__borg_archive'\
|
2018-01-10 21:32:22 +00:00
|
|
|
|
'3:tar:_files'\
|
|
|
|
|
'4:path:_files'\
|
|
|
|
|
--tar-filter'[filter program to pipe data through]'\
|
|
|
|
|
--list'[output verbose list of items (files, dirs, ...)]'\
|
|
|
|
|
{-e,--exclude}'[exclude paths matching PATTERN]:PATTERN'\
|
|
|
|
|
--exclude-from'[read exclude patterns from EXCLUDEFILE, one per line]:_files'\
|
|
|
|
|
--pattern'[experimental: include/exclude paths matching PATTERN]:PATTERN'\
|
|
|
|
|
--patterns-from'[experimental: read include/exclude patterns from PATTERNFILE, one per line]:_files'\
|
|
|
|
|
--strip-components'[Remove the specified number of leading path elements. Paths with fewer elements will be silently skipped.]:NUMBER'\
|
|
|
|
|
$borg_common_options
|
2017-11-04 15:54:21 +00:00
|
|
|
|
;;
|
2018-01-10 21:32:22 +00:00
|
|
|
|
(serve)
|
|
|
|
|
_arguments \
|
|
|
|
|
--restrict-to-path'[restrict repository access to PATH]:_files'\
|
|
|
|
|
--restrict-to-repository'[restrict repository access]:_files'\
|
|
|
|
|
--append-only'[only allow appending to repository segment files]'\
|
|
|
|
|
--storage-quota'[Override storage quota of the repository]:QUOTA'\
|
|
|
|
|
$borg_common_options
|
|
|
|
|
;;
|
|
|
|
|
(config)
|
2017-11-04 15:54:21 +00:00
|
|
|
|
_arguments \
|
|
|
|
|
'2:archives:__borg_archive'\
|
2018-01-10 21:32:22 +00:00
|
|
|
|
'3:name:NAME'\
|
|
|
|
|
'4:value:VALUE'\
|
|
|
|
|
{-c,--cache}'[get and set values from the repo cache]'\
|
2018-06-22 21:53:44 +00:00
|
|
|
|
{-d,--delete}'[delete the key from the config]'\
|
|
|
|
|
--list'[list the configuration of the repo]'\
|
2018-01-10 21:32:22 +00:00
|
|
|
|
$borg_common_options
|
2017-11-04 15:54:21 +00:00
|
|
|
|
;;
|
|
|
|
|
(with-lock)
|
|
|
|
|
_arguments \
|
|
|
|
|
'(-)2:archives:__borg_archive'\
|
2018-01-10 21:32:22 +00:00
|
|
|
|
$borg_common_options
|
2017-11-04 15:54:21 +00:00
|
|
|
|
#'3:command:_command_names -e'\
|
|
|
|
|
#'4:arguments:_normal'
|
|
|
|
|
#TODO Debug this, getting "_tags:comptags:36: nesting level too deep" error
|
|
|
|
|
;;
|
2018-01-10 21:32:22 +00:00
|
|
|
|
(break-lock)
|
|
|
|
|
_arguments \
|
|
|
|
|
'2:archives:__borg_archive'\
|
|
|
|
|
$borg_common_options
|
|
|
|
|
;;
|
2017-11-04 15:54:21 +00:00
|
|
|
|
(benchmark)
|
|
|
|
|
_arguments \
|
|
|
|
|
'2:type:(crud)'\
|
|
|
|
|
'3:repo:_files'\
|
|
|
|
|
'4:path:_files'\
|
2018-01-10 21:32:22 +00:00
|
|
|
|
$borg_common_options
|
2017-11-04 15:54:21 +00:00
|
|
|
|
;;
|
2019-02-06 15:49:31 +00:00
|
|
|
|
(help)
|
|
|
|
|
_arguments \
|
|
|
|
|
'2:type:(patterns placeholders compression )'\
|
|
|
|
|
$borg_common_options
|
|
|
|
|
;;
|
2017-11-04 15:54:21 +00:00
|
|
|
|
*)
|
|
|
|
|
commands=(
|
|
|
|
|
'init:initialize empty repository'
|
|
|
|
|
'create:create backup'
|
|
|
|
|
'extract:extract archive contents'
|
2018-01-10 21:32:22 +00:00
|
|
|
|
'check:verify repository'
|
2017-11-04 15:54:21 +00:00
|
|
|
|
'rename:rename archive'
|
|
|
|
|
'list:list archive or repository contents'
|
2018-01-10 21:32:22 +00:00
|
|
|
|
'diff:find differences in archive contents'
|
|
|
|
|
'delete:delete archive'
|
|
|
|
|
'prune:prune archives'
|
2019-02-08 15:44:36 +00:00
|
|
|
|
'compact:free repository space'
|
2018-01-10 21:32:22 +00:00
|
|
|
|
'info:show repository or archive information'
|
2017-11-04 15:54:21 +00:00
|
|
|
|
'mount:mount repository'
|
|
|
|
|
'umount:umount repository'
|
2018-01-10 21:32:22 +00:00
|
|
|
|
'key:manage repository key'
|
2017-11-04 15:54:21 +00:00
|
|
|
|
'upgrade:upgrade repository format'
|
2018-01-10 21:32:22 +00:00
|
|
|
|
'recreate:recreate contents of existing archives'
|
|
|
|
|
'export-tar:create tarball from archive'
|
|
|
|
|
'serve:start repository server process'
|
|
|
|
|
'config:get/set options in repo/cache config'
|
2017-11-04 15:54:21 +00:00
|
|
|
|
'with-lock:run user command with lock held'
|
2018-01-10 21:32:22 +00:00
|
|
|
|
'break-lock:break repository and cache locks'
|
2017-11-04 15:54:21 +00:00
|
|
|
|
'benchmark:benchmark command'
|
2019-02-06 15:49:31 +00:00
|
|
|
|
'help:miscellaneous help'
|
2017-11-04 15:54:21 +00:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
_describe 'values' commands
|
2018-01-10 21:32:22 +00:00
|
|
|
|
_arguments $borg_common_options
|
|
|
|
|
|
2017-11-04 15:54:21 +00:00
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
__borg_archive() {
|
2019-03-15 16:40:47 +00:00
|
|
|
|
__borg_list_archives 1
|
|
|
|
|
}
|
|
|
|
|
__borg_archive2() {
|
|
|
|
|
__borg_list_archives 2
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
__borg_list_archives() {
|
2017-11-04 15:54:21 +00:00
|
|
|
|
local -a items
|
2019-03-15 16:40:47 +00:00
|
|
|
|
local cpath
|
|
|
|
|
cpath=`expr match "${words}" "\(.*\)::"`
|
|
|
|
|
cpath=${cpath##* }
|
|
|
|
|
if (( $1 == 1 )); then
|
|
|
|
|
# To achieve "repository::archive" listing:
|
|
|
|
|
prefix_repo="${cpath}::"
|
|
|
|
|
fi
|
|
|
|
|
if (( $1 == 2 )); then
|
|
|
|
|
# To achieve only "archive" listing:
|
|
|
|
|
prefix_repo=
|
2017-11-04 15:54:21 +00:00
|
|
|
|
fi
|
2019-03-15 16:40:47 +00:00
|
|
|
|
items=("${(@f)$(borg list --format=$prefix_repo\{archive\}\{NEWLINE\} $cpath 2>/dev/null)}")
|
2017-11-04 15:54:21 +00:00
|
|
|
|
if [[ $items[1] == "" ]]; then
|
|
|
|
|
_files -/
|
|
|
|
|
else
|
|
|
|
|
_wanted archives expl 'archive' compadd $items
|
|
|
|
|
fi
|
|
|
|
|
}
|