Repository

Looks good to me!

User Tools

Site Tools


kb:intranet:services:backup:kopia:start

Kopia

Changelog

  • 2026-03-23: Init

Getting started: https://kopia.io/docs/getting-started/

A more proper way to do things...

Kopia repository must be created by specifying all the repository parameters on CLI directly (whyyyy), because the create from-config subroutine requires an existing token... Instead, write the command in a file then execute it, so that the command does not leak unnecessarily. Something like

run.sh
#!/bin/sh
kopia repository create s3 \
    --region ap-southeast-1 \
    --bucket ... \
    --access-key ... \
    --secret-access-key ...

Optionally test the repository for feasibility: kopia repository validate-provider. After which, retrieve the token with kopia repository -t -s, and store it in a file, say, repository.token. Use a cache and log directory with sufficient capacity. Repository can be reconnected to with:

kopia repository connect from-config \
    --token-file [TOKENFILE] \
    --cache-directory [DIRPATH] \
    --log-dir [DIRPATH]

Warning

Log directory is not respected on kopia v0.21.1. Better to make a softlink to the target cache directory instead.

mkdir -p ~/.cache
ln -s [DIRPATH] ~/.cache/kopia
kopia repository connect from-config --token-file [TOKENFILE]

Note this is also better because the cache specific to each repository is automatically created as well, under the cache directory (rather than putting them all in the root cache directory itself).

First order of business is to define the storage class (or use something else you prefer, see list). As of March 2026, you'd mostly likely want one of STANDARD, STANDARD_IA, or GLACIER_IR:

.storageconfig
{
   "blobOptions": [
     { "prefix": "p", "storageClass": "STANDARD_IA" },
     { "storageClass": "STANDARD" }
  ]
}
aws s3 cp .storageconfig s3://[BUCKET]/

Working with backups:

kopia snapshot create [DIRPATH]
kopia snapshot delete [ID]  # e.g. from partial snapshot

# Browse directory
kopia snapshot list [DIRPATH]  # yields repository ID
kopia ls -l [ID]
mkdir /tmp/mnt
kopia mount [ID] /tmp/mnt &

Working with snapshot policies. Note automated snapshot policies are not in force for CLI-based usage, see forum answer. Use cron with kopia snapshot create --all instead.

Policies

Note that the repository configuration is cached, so no need to invoke a connection script prior to snapshots. Using cron instead:

/etc/crontab
45  4  *   *   *   root    /usr/local/bin/kopia snapshot create --all
kb/intranet/services/backup/kopia/start.txt · Last modified: 3 weeks ago (25 March 2026) by Justin