rustfs
Small CLI for RustFS/S3 workflows with short, human-oriented commands.
What It Does
- Upload files/folders to a bucket
- Download keys from a bucket
- Remove keys from a bucket (all versions)
- Move and copy keys within a bucket, versions included
- List bucket contents with modtime + size
- List buckets
- Diff a local path against its remote counterpart
- Browse local and remote side by side in a TUI
- Expire noncurrent versions by the bucket lifecycle rules (
gc) - Create buckets
- Open RustFS console URL
- Match local files against a glob
- Toggle exclude/include patterns in
./.env - Self-update from Gitea releases
- Run restic against that repo: init/backup on push, forget/prune on prune
- Inspect/set selected bucket config keys
- Write effective env to
./.env
Install / Run
go run . help
Built binary usage:
./rfs.exe help
Environment
Load order:
- CLI flags (for example
--endpoint,--workdir) ./.env(working directory)- process environment
Flag names map directly from env names:
RUSTFS_ENDPOINT->--endpointRUSTFS_ACCESS_KEY->--access-keyRUSTFS_SECRET_KEY->--secret-keyRUSTFS_BUCKET->--bucket/-dRUSTFS_WORKDIR->--workdirRUSTFS_CONSOLE_ENDPOINT->--console-endpoint
Variables:
RUSTFS_ENDPOINT(required)RUSTFS_ACCESS_KEY(required for S3 endpoints and upload/download/list/remove/create)RUSTFS_SECRET_KEY(required for S3 endpoints and upload/download/list/remove/create)RUSTFS_BUCKET(optional; required for everyrfs resticcommand, S3 or local, and for commands that target a bucket)RUSTFS_WORKDIR(optional)RUSTFS_CONSOLE_ENDPOINT(optional)RUSTFS_RESTIC_PASSWORD(required forrfs restic)RUSTFS_EXCLUDES(optional CSV of exclude globs, applied with--exclude)RUSTFS_INCLUDES(optional CSV of include globs, applied with--include)RUSTFS_SKIP_IF_UNCHANGED(optional; upload/download skip when local MD5 equals remote ETag)RUSTFS_WORKERS(optional, default32)RUSTFS_RESTIC_KEEP_LAST(required forrfs restic prune; there is no default, and a value below1is refused rather than forgetting every snapshot)RUSTFS_RESTIC_SKIP_IF_UNREADABLE(optional forrfs restic; unset meansfalse)RUSTFS_RESTIC_KEEP(optional, flag--keep; a restore leaves files the snapshot does not hold where they are; unset meansfalse)RUSTFS_RESTIC_VC_PERIOD(required forrfs restic vc, seconds)
Commands
Upload
rfs upload file.txt
rfs upload -d mybucket file.txt
rfs upload foo/bar:baz
rfs upload .git/:bar
rfs upload '**/*.go'
rfs upload '**/*.go' -e '**/*_test.go' -e 'vendor/**'
Upload remap syntax:
SOURCE:NAMEis allowed on any input.SOURCEis the local file/folder path.NAMEis the target key/path in the bucket.*:NAMEis invalid.- Inputs support doublestar globs.
--exclude/-eis repeatable.
Workdir key prefixing:
- If
RUSTFS_WORKDIRis set, object keys are prefixed with that path forupload,download,remove, andls. - Example:
RUSTFS_WORKDIR=barandrfs upload foobaruses keybar/foobar.
Bucket for upload/download/list/remove/config/create: RUSTFS_BUCKET or --bucket / -d.
Download
rfs download key1 key2
rfs download -d mybucket key1 key2
rfs download go/release.sh:release.sh
rfs download '**/*.tar' -e 'tmp/**'
Download remap syntax:
KEY:NAMEdownloads remoteKEYto localNAME.- Keys support doublestar globs.
--exclude/-eis repeatable.
Remove
rfs remove key1 key2
rfs remove -d mybucket key1 key2
rfs remove '**/*.tar' -e 'keep/**'
Removes each key and all of its versions/delete markers.
Keys support doublestar globs.
--exclude / -e is repeatable.
List
rfs ls
rfs ls path/to/folder
rfs ls path to folder
rfs ls -d mybucket path/to/folder
Prints MODIFIED SIZE NAME with human-readable sizes.
Move / Copy
rfs move key1 key2 dest/
rfs mv 'logs/**/*.tar' archive/
rfs copy notes.txt notes.bak
rfs cp src/ dst/
Both take one or more source keys followed by a destination, and both carry
every version of each source key across, preserving version order. Delete
markers are not copied, because S3 cannot copy one. move is copy + delete: if
any copy fails the source is left in place.
A destination ending in / is a prefix; without one, a single source key is an
exact rename.
Diff
rfs diff src/main.go
rfs diff ./somedir
Unified diff of a local file against its remote counterpart. For a directory, lists added, removed and changed files instead.
Bucket
rfs bucket list
rfs bucket list prefix
Lists buckets on the endpoint.
Gc
rfs gc
Deletes noncurrent versions that exceed the bucket's own lifecycle rule
(rfs-Lifecycle-NoncurrentVersionExpiration) — older than NoncurrentDays, or
beyond NewerNoncurrentVersions. The current version of each key is always
kept. With no such rule configured, it does nothing.
Set the rule with rfs config (below). Alias of the old tidy command.
Exclude / Include
rfs exclude '**/*.tmp' 'node_modules/**'
rfs include '**/*.go'
Toggles patterns in RUSTFS_EXCLUDES / RUSTFS_INCLUDES in ./.env: a pattern
already present is removed, a missing one is added.
TUI
rfs tui
rfs ui
rfs tui --logFile ./tmp/rfs-tui.log
Contract: docs/tui.md.
Config
rfs config
rfs config Lifecycle NewerNoncurrentVersions 5
rfs config Lifecycle NoncurrentDays 1
rfs -d mybucket config Lifecycle NoncurrentDays 1
config output is table-oriented:
CONFIG | KEY | VALUE
Current key implemented:
Lifecycle NewerNoncurrentVersionsLifecycle NoncurrentDays
These map to S3 lifecycle NoncurrentVersionExpiration.NewerNoncurrentVersions
and NoncurrentVersionExpiration.NoncurrentDays.
Env
rfs env
Rewrites ./.env with canonical rfs variable names. Resolution per key:
- CLI flags (global flags such as
--endpoint,--bucket/-d, etc.) ./.envafter v1 → v2 migration (see below)- process environment
Embedded .env is not read by this command.
v1 → v2 migration (only in rfs env): deprecated names RUSTFS_DEFAULT_BUCKET and RESTIC_* tuning keys are promoted to RUSTFS_BUCKET and RUSTFS_RESTIC_* and removed from the written file. Run rfs env once after upgrading to rewrite ./.env.
Unset or empty resolved values are written as # KEY= (commented) so the file does not assign empty strings for keys you have not set.
Create
rfs create
rfs -d mybucket create
Creates the bucket named in RUSTFS_BUCKET (or flags)
Match
rfs match '**/*_test.go'
rfs match 'node_modules/**'
Lists local paths that match the provided glob. This is useful for previewing
which local entries an --exclude pattern would match.
Restic
rfs restic
rfs restic push
rfs restic pull
rfs restic pull 0
rfs restic rm
rfs restic find foobar
rfs restic stat
rfs restic stat 0
rfs restic prune
rfs restic prune --restic-keep-last 7
rfs restic --tag daily
rfs restic push -t daily -t prod
rfs restic push -e '**/*.tmp' -e 'node_modules/**'
rfs restic push --restic-skip-if-unreadable
rfs restic pull -i worlds/save1 -i mirrors
The subcommands are push, pull, rm, find, stats, prune, check,
diff, unlock, recover, repair, setup, vc and daemon.
Any unambiguous prefix works, which is why rfs restic stat reaches stats.
rfs restic defaults to rfs restic push.
Every restic command that opens the repository needs RUSTFS_BUCKET and
RUSTFS_RESTIC_PASSWORD, from any of the config sources. There is no
requirement for a ./.env file specifically. Two commands are exceptions:
setup writes those settings rather than using them, and daemon resolves them
per watched directory as each backup comes due rather than for itself. vc does
need them, on every cycle, because each cycle is a push in the directory it
was started in.
rfs restic pull lists snapshots in a simple interactive picker and (after
confirmation) runs restic restore <snapshot> --target . --delete, which makes
the directory a mirror of the snapshot: matching paths are overwritten and local
files that are not in the snapshot are deleted, except those the excludes leave
out of the restore. RUSTFS_RESTIC_KEEP or --keep drops --delete, so local
files the snapshot does not hold stay, and rfs restic diff and the vc
daemon's preview then report none of them. The vc daemon's pull button is the other way to reach it: it is
rfs restic pull 0 -y for one watched directory, confirmed by clicking the
button a second time, and it runs on that directory's own goroutine so it
cannot overlap a backup of the same repository.
pull, rm and stats each take one optional argument, which picks a snapshot
instead of prompting. It is an index, not a path: 0 is the newest, 1 to N
count from the oldest, and ~N counts back from the newest, so ~1 is the one
before the newest. A second argument is an error.
A restore is scoped by includes, not by positional arguments. With
RUSTFS_INCLUDES or -i/--include set, only those paths are restored, as
restic restore --include. Restoring a whole snapshot instead applies
RUSTFS_EXCLUDES or -e/--exclude as restic restore --exclude. The two do
not combine: includes, when present, decide the restore on their own.
rfs restic rm lists snapshots in the same interactive picker and (after
confirmation) removes the selected snapshot using restic forget SNAPSHOT --prune.
rfs restic find <pattern> [pattern...] runs restic find with those patterns.
rfs restic stat shows repository stats (no snapshot arg). rfs restic stat 0
shows latest snapshot stats (0 means latest in picker indexing).
rfs restic infers repository type from RUSTFS_ENDPOINT:
^(s3|https?)://-> remote S3 restic repo (s3:<endpoint>/<RUSTFS_BUCKET>[/RUSTFS_WORKDIR])- anything else -> local filesystem restic repo (
<endpoint>/<RUSTFS_BUCKET>[/RUSTFS_WORKDIR])
The bucket is part of the path either way; only the s3: prefix depends on the
endpoint being remote.
rfs restic push runs these restic calls in order against the resolved repo:
restic -r "$URL" snapshots, andinitif that failsrestic -r "$URL" unlockrestic -r "$URL" backup ., with an--excludeper exclude pattern and a--tagper tag, and--skip-if-unchangedalways
It stops there. Forgetting old snapshots and pruning their data is
rfs restic prune, a separate subcommand that runs
restic forget --keep-last N and then restic prune. Nothing runs it on a
period; the vc daemon's collect button is the other way to reach it.
Environment used for each restic call, on top of the environment rfs itself
was run with:
RESTIC_PASSWORDfromRUSTFS_RESTIC_PASSWORDAWS_ACCESS_KEY_IDfromRUSTFS_ACCESS_KEY(S3 endpoints only)AWS_SECRET_ACCESS_KEYfromRUSTFS_SECRET_KEY(S3 endpoints only)
The restic settings are read from the config chain like every other one, and
their flags carry the restic- prefix their variables do:
--restic-keep-last, --restic-skip-if-unreadable, --restic-password,
--restic-version-control-period. Only --restic-keep-last reaches restic as
an argument, on the forget that rfs restic prune runs.
rfs restic also accepts the global --exclude/-e patterns, merges them with
RUSTFS_EXCLUDES, and forwards all of them to restic as --exclude arguments
on the backup step. Snapshot tags can be set with --tag/-t (repeatable) and
are forwarded to restic as --tag arguments on the backup step. There is no
RUSTFS_RESTIC_TAG: tags are a flag only.
RUSTFS_RESTIC_SKIP_IF_UNREADABLE is not passed to restic at all, and is off
unless set. It decides what rfs restic push does when restic backup fails:
off, the error is returned and the command exits non-zero; on, the failure is
logged as a warning and the push reports success. It is there for a backup that
restic could not read every file of, so setting it means a genuinely failed
backup exits 0 too.
Update
rfs update
rfs update --check
rfs update v1.13.4
rfs update uses github.com/creativeprojects/go-selfupdate with its Gitea
provider to detect and apply the newest release for the current platform.
The update target is the currently running executable path, so if the binary was renamed locally, the updated binary keeps that same local name.
Version
rfs version
rfs --version
Layout
main.go calls cmd.NewRootCmd().Execute(), nothing else
cmd/ one file per command: flags, validation, one call into internal/
clientctx/ the S3 client on the cobra context, shared by every command tree
config/ rfs config lifecycle|versioning
restic/ rfs restic ...
internal/ all the logic, plain Go, no cobra
buckets/ bucket listing
buildinfo/ version stamped in at build time
dirdiff/ local vs remote comparison, for the diff command and the TUI
dotenv/ reading and editing ./.env
listing/ turning list pages into printable rows
progress/ op progress and human-readable sizes
s3load/ building a client from the resolved config
selfupdate/ replacing the binary from a Gitea release
tui/ the TUI itself, which knows nothing about S3
tuihost/ tui.Host implemented against the S3 client
s3/ the importable library: client, config, restic
Commands hold no logic and internal/ imports no cobra, so everything in
internal/ is testable as plain function calls.
Build
task
task builds the vc daemon's UI with bun, injects version metadata, builds the
Windows and Linux binaries, compresses them with UPX and copies rfs.exe to
GOPATH/bin.
The daemon's UI is an Astro project in internal/vcdaemon/ui, built to
ui/dist and embedded with go:embed, so bun is needed to compile the
binary at all: the build output is generated rather than committed, and a clean
clone has to run go generate ./... before go build or go test will work.
Release (vet, tag, build, Gitea release with the binaries attached):
task release
Checks (formatting, vet, qlty, complexity) - run before committing:
./vet.sh