Initial import of the existing CephFS subvolume migration prototype, including the native libcephfs transport, rsync backend, local Ceph lab environment and integration tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
58 lines
1.1 KiB
Go
58 lines
1.1 KiB
Go
//go:build ceph && cgo
|
|
|
|
package main
|
|
|
|
import (
|
|
"CephMig/internal/cephfsnative"
|
|
"CephMig/internal/storage"
|
|
"encoding/json"
|
|
"flag"
|
|
"fmt"
|
|
"io"
|
|
"os"
|
|
)
|
|
|
|
func main() {
|
|
config := flag.String("config", "/lab/migration.example.json", "config")
|
|
root := flag.String("root", "/", "path to stat, or snapshot root")
|
|
rel := flag.String("rel", ".", "relative snapshot path")
|
|
a := flag.String("from", "", "previous snapshot")
|
|
b := flag.String("to", "", "current snapshot")
|
|
flag.Parse()
|
|
data, err := os.ReadFile(*config)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
var c struct{ Source storage.Options }
|
|
if err = json.Unmarshal(data, &c); err != nil {
|
|
panic(err)
|
|
}
|
|
fs, err := cephfsnative.Open(c.Source)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
defer fs.Close()
|
|
n, err := fs.Stat(*root)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
json.NewEncoder(os.Stdout).Encode(n)
|
|
if *a != "" {
|
|
d, err := fs.SnapDiff(*root, *rel, *a, *b)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
defer d.Close()
|
|
for {
|
|
name, err := d.Next()
|
|
if err == io.EOF {
|
|
break
|
|
}
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
fmt.Printf("diff: %q\n", name)
|
|
}
|
|
}
|
|
}
|