restic backup(1)

NAME
restic-rewrite - Rewrite snapshots to exclude files or change metadata

SYNOPSIS
restic rewrite [flags] [snapshotID ...]

DESCRIPTION
The "rewrite" command creates new snapshots from existing ones. You can use exclude or include filters to control which files are included in the new snapshots. Unless --new-host or --new-time is specified, metadata (time, host, tags) is preserved.

The snapshots to rewrite are specified using the --host, --tag and --path options, or by providing a list of snapshot IDs. Please note that specifying neither any of these options nor a snapshot ID will cause the command to rewrite all snapshots.

The special tag 'rewrite' will be added to the new snapshots to distinguish them from the original ones, unless --forget is used. If the --forget option is used, the original snapshots will instead be directly removed from the repository.

Please note that the --forget option only removes the snapshots and not the actual data stored in the repository. In order to delete the no longer referenced data, use the "prune" command.

When rewrite is used with the --snapshot-summary option, a new snapshot is created containing statistics summary data. Only two fields in the summary will be non-zero: TotalFilesProcessed and TotalBytesProcessed.

When rewrite is called with one of the --exclude or --include options, TotalFilesProcessed and TotalBytesProcessed will be updated in the snapshot summary.

EXIT STATUS
Exit status is 0 if the command was successful. Exit status is 1 if there was any error. Exit status is 10 if the repository does not exist. Exit status is 11 if the repository is already locked. Exit status is 12 if the password is incorrect.

OPTIONS
-n, --dry-run[=false]
    do not do anything, just print what would be done

-e, --exclude=[]
    exclude a pattern (can be specified multiple times)

--exclude-file=[]
    read exclude patterns from a file (can be specified multiple times)

--forget[=false]
    remove original snapshots after creating new ones

-h, --help[=false]
    help for rewrite

-H, --host=[]
    only consider snapshots for this host (can be specified multiple times, use empty string to unset default value) (default: $RESTIC_HOST)

--iexclude=[]
    same as --exclude pattern but ignores the casing of filenames

--iexclude-file=[]
    same as --exclude-file but ignores casing of filenames in patterns

--iinclude=[]
    same as --include pattern but ignores the casing of filenames

--iinclude-file=[]
    same as --include-file but ignores casing of filenames in patterns

-i, --include=[]
    include a pattern (can be specified multiple times)

--include-file=[]
    read include patterns from a file (can be specified multiple times)

--new-host=""
    replace hostname

--new-time=""
    replace time of the backup

--path=[]
    only consider snapshots including this (absolute) path (can be specified multiple times, snapshots must include all specified paths)

-s, --snapshot-summary[=false]
    create snapshot summary record if it does not exist

--tag=[]
    only consider snapshots including tag[,tag,...] (can be specified multiple times)

OPTIONS INHERITED FROM PARENT COMMANDS
--cacert=[]
    file to load root certificates from (default: use system certificates or $RESTIC_CACERT)

--cache-dir=""
    set the cache directory. (default: use system default cache directory)

--cleanup-cache[=false]
    auto remove old cache directories

--compression=auto
    compression mode (only available for repository format version 2), one of (auto|off|fastest|better|max) (default: $RESTIC_COMPRESSION)

--http-user-agent=""
    set a http user agent for outgoing http requests

--insecure-no-password[=false]
    use an empty password for the repository, must be passed to every restic command (insecure)

--insecure-tls[=false]
    skip TLS certificate verification when connecting to the repository (insecure)

--json[=false]
    set output mode to JSON for commands that support it

--key-hint=""
    key ID of key to try decrypting first (default: $RESTIC_KEY_HINT)

--limit-download=0
    limits downloads to a maximum rate in KiB/s. (default: unlimited)

--limit-upload=0
    limits uploads to a maximum rate in KiB/s. (default: unlimited)

--no-cache[=false]
    do not use a local cache

--no-extra-verify[=false]
    skip additional verification of data before upload (see documentation)

--no-lock[=false]
    do not lock the repository, this allows some operations on read-only repositories

-o, --option=[]
    set extended option (key=value, can be specified multiple times)

--pack-size=0
    set target pack size in MiB, created pack files may be larger (default: $RESTIC_PACK_SIZE)

--password-command=""
    shell command to obtain the repository password from (default: $RESTIC_PASSWORD_COMMAND)

-p, --password-file=""
    file to read the repository password from (default: $RESTIC_PASSWORD_FILE)

-q, --quiet[=false]
    do not output comprehensive progress report

-r, --repo=""
    repository to backup to or restore from (default: $RESTIC_REPOSITORY)

--repository-file=""
    file to read the repository location from (default: $RESTIC_REPOSITORY_FILE)

--retry-lock=0s
    retry to lock the repository if it is already locked, takes a value like 5m or 2h (default: no retries)

--stuck-request-timeout=5m0s
    duration after which to retry stuck requests

--tls-client-cert=""
    path to a file containing PEM encoded TLS client certificate and private key (default: $RESTIC_TLS_CLIENT_CERT)

-v, --verbose[=0]
    be verbose (specify multiple times or a level using --verbose=n``, max level/times is 2)

SEE ALSO
restic(1)