Files
quartz/content/10-19 LIFE/13 TECH SETUP/13.12 PROCESSES/Backups.md
Quartz Syncer 536652b5b6
All checks were successful
Build and Deploy Quartz / build (push) Successful in 22s
Published multiple files
2026-01-21 22:48:48 -07:00

3.0 KiB

publish, title, created, modified, cssclasses
publish title created modified cssclasses
true Backups 2026-01-20T13:21:41.646-07:00 2026-01-21T22:48:12.310-07:00

Local

For me local backups happen in two main ways

  1. Backups to a VPS using 20-29 HOBBYS/22 SELF HOSTING/22.12 SERVICES/Syncthing
  2. Backups to a USB stick that lives in my emergency kit

USB Backups

For USB backups I had a few key requirements

  1. They must be encrypted
  2. Decryption should be able to take place on any Windows, Mac, or Linux device
  3. Decryption must be simple enough that an intermediate user should be able to manage it given instructions (this is in case someone needs this data if I am no longer around to impart my wisdom)

Given these requirements I settled on using 10-19 LIFE/13 TECH SETUP/13.11 APPS/VeraCrypt to create an encrypted container formatted with exFat on a USB drive. This way someone can install the software and, given my key, decrypt the data.

I created the following helper functions to make this processes a little less cumbersome for myself on a monthly basis.

Mount/Unmount Container

vault() {
    local mount_base="/run/media/$USER"
    local mount_point="$mount_base/vault"

    _vault_find() {
        local container
        container=$(command find "$mount_base" -maxdepth 2 -name "DataVault" -type f 2>/dev/null | head -1)

        if [[ -z "$container" ]]; then
            echo "Error: DataVault not found under $mount_base" >&2
            return 1
        fi
        echo "$container"
    }

    case "${1:-}" in
        m|mount)
            local container
            container=$(_vault_find) || return 1

            if mountpoint -q "$mount_point" 2>/dev/null; then
                echo "Already mounted at $mount_point"
                return 0
            fi

            echo "Found: $container"
            sudo mkdir -p "$mount_point"
            sudo veracrypt -t --fs-options="uid=$(id -u),gid=$(id -g)" "$container" "$mount_point"
            echo "Mounted at $mount_point"
            ;;
        u|unmount)
            if ! mountpoint -q "$mount_point" 2>/dev/null; then
                echo "Not mounted"
                return 0
            fi
            sudo veracrypt -t -d "$mount_point"
            sudo rmdir "$mount_point" 2>/dev/null || true
            echo "Unmounted"
            ;;
        *)
            echo "Usage: vault {mount|m|unmount|u}"
            return 1
            ;;
    esac
}

Sync Data

vault-sync() {
    local mount_point="/run/media/$USER/vault"
    local source="$HOME/DataStore"

    if ! mountpoint -q "$mount_point" 2>/dev/null; then
        echo "Error: Vault not mounted at $mount_point" >&2
        return 1
    fi

    if [[ ! -d "$source" ]]; then
        echo "Error: Source directory $source does not exist" >&2
        return 1
    fi

    rsync -av --delete "$source/" "$mount_point/"
    echo "Sync complete"
}

Cloud

For services on my VPS's I backup docker volumes using docker-volume-backup