Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8d586ed4f9 |
No files matched your search
@@ -127,11 +127,6 @@ vaultik config set s3.secret_access_key "..."
|
||||
vaultik snapshot list
|
||||
```
|
||||
|
||||
For an rclone destination, the storage credentials are in rclone's config file
|
||||
instead. Copy that file to the new host, or recreate it with `rclone config`,
|
||||
and set `storage_url` to the original `rclone://remote/path`. See
|
||||
[storage backends](#storage-backends).
|
||||
|
||||
`snapshot list` reads the destination store without the private key. A snapshot
|
||||
that is not in this host's (empty) local index is shown as remote-only: its row
|
||||
is identified by `<remote only:...>` rather than by a `hostname_name_timestamp`
|
||||
@@ -286,8 +281,6 @@ work as written.
|
||||
the key is not typed into your shell history.
|
||||
- `VAULTIK_CONFIG`: Path to config file (overridden by `--config`)
|
||||
- `VAULTIK_INDEX_PATH`: Override local SQLite index path
|
||||
- `RCLONE_CONFIG`: Path to the rclone config file used by an `rclone://`
|
||||
destination (default `~/.config/rclone/rclone.conf`)
|
||||
- `VAULTIK_CPUPROFILE`: Write a CPU profile to this path for the duration of the
|
||||
run (development/debugging)
|
||||
- `VAULTIK_MEMPROFILE`: Write a heap profile to this path when the run exits
|
||||
@@ -609,11 +602,7 @@ only `vaultik-destination.txt` stops such a backup, and only while the local
|
||||
index holds snapshots.
|
||||
|
||||
**Rclone** (`rclone://remote/path`): Uses rclone's 70+ supported cloud
|
||||
providers. `remote` is the name of a remote in rclone's config file, which holds
|
||||
that remote's credentials. vaultik reads the same file the `rclone` tool reads,
|
||||
by default `~/.config/rclone/rclone.conf`. Create it with `rclone config`, or
|
||||
copy it from another machine; vaultik does not need the `rclone` tool once the
|
||||
file exists. The `RCLONE_CONFIG` environment variable names a different file.
|
||||
providers. Requires rclone to be configured separately (`rclone config`).
|
||||
|
||||
An upload cut off part-way leaves nothing under the object's name on S3, which
|
||||
shows an object only once its upload has completed, and on the local filesystem
|
||||
|
||||
@@ -4,8 +4,10 @@ package snapshot
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"syscall"
|
||||
"testing"
|
||||
|
||||
"github.com/spf13/afero"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
@@ -38,3 +40,36 @@ func TestDeviceNumberFromStat(t *testing.T) {
|
||||
// /dev is a different filesystem from the temp dir on Linux, macOS and in Docker.
|
||||
assert.NotEqual(t, deviceOf(dir), deviceOf("/dev"))
|
||||
}
|
||||
|
||||
// fileInfoWithStat is a file's info whose Sys returns stat.
|
||||
type fileInfoWithStat struct {
|
||||
os.FileInfo
|
||||
|
||||
stat *syscall.Stat_t
|
||||
}
|
||||
|
||||
func (i fileInfoWithStat) Sys() any { return i.stat }
|
||||
|
||||
// The in-memory test filesystem has no device numbers. The pinned afero
|
||||
// gives no stat; its unreleased master gives a stat holding only uid, gid
|
||||
// and size. See https://git.eeqj.de/sneak/vaultik/issues/462.
|
||||
func TestDeviceNumberFromStatInMemory(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
fs := afero.NewMemMapFs()
|
||||
require.NoError(t, afero.WriteFile(fs, "/file.txt", []byte("data"), 0o600))
|
||||
|
||||
info, err := fs.Stat("/file.txt")
|
||||
require.NoError(t, err)
|
||||
|
||||
_, ok := deviceNumberFromStat(info)
|
||||
assert.False(t, ok, "device number read from a file info with no stat")
|
||||
|
||||
zeroed := fileInfoWithStat{
|
||||
FileInfo: info,
|
||||
stat: &syscall.Stat_t{Uid: 1000, Gid: 1000, Size: 4},
|
||||
}
|
||||
|
||||
_, ok = deviceNumberFromStat(zeroed)
|
||||
assert.False(t, ok, "device number read from a stat with no device or inode number")
|
||||
}
|
||||
@@ -1438,11 +1438,12 @@ func (s *Scanner) deviceNumberAt(path string) (uint64, bool) {
|
||||
}
|
||||
|
||||
// deviceNumberFromStat returns the number of the device that holds the
|
||||
// file info describes, and false when info carries no stat, as from the
|
||||
// in-memory test filesystem.
|
||||
// file info describes, and false when info carries no stat from a real
|
||||
// filesystem. The in-memory test filesystem gives either no stat or one
|
||||
// whose device and inode numbers are both zero, which no real file has.
|
||||
func deviceNumberFromStat(info os.FileInfo) (uint64, bool) {
|
||||
stat, ok := info.Sys().(*syscall.Stat_t)
|
||||
if !ok {
|
||||
if !ok || (stat.Dev == 0 && stat.Ino == 0) {
|
||||
return 0, false
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user