seafile_recovery/seafile_recovery.go

48 lines
1.4 KiB
Go
Raw Normal View History

2021-04-21 12:25:35 +00:00
package main
import (
"log"
"github.com/docopt/docopt-go"
)
func main() {
usage := `Seafile Recovery.
Usage:
2021-04-22 09:29:04 +00:00
seafile_recovery [--storage=<sto>] head <repoid>
2021-04-22 10:38:52 +00:00
seafile_recovery [--storage=<sto>] ls <repoid> <pathid>
seafile_recovery [--storage=<sto>] dump <repoid> <pathid>
seafile_recovery [--storage=<sto>] s3 <repoid> <pathid> <bucket>
2021-04-21 12:25:35 +00:00
seafile_recovery (-h | --help)
Options:
-h --help Show this screen
--storage=<sto> Set Seafile storage path [default: ./storage]`
2021-04-21 12:44:49 +00:00
var config configCollect
2021-04-21 12:25:35 +00:00
opts, err := docopt.ParseDoc(usage)
if err != nil { log.Fatal(err) }
opts.Bind(&config)
2021-04-21 12:44:49 +00:00
checkRootFolder(config.Storage)
2021-04-21 13:54:50 +00:00
rexists := repoExistsIn(config.Storage, config.RepoId)
2021-04-21 12:44:49 +00:00
2021-04-22 09:29:04 +00:00
if config.Head {
2021-04-21 13:54:50 +00:00
if !rexists["commits"] { log.Fatal("No commits folder found for repo ",config.RepoId) }
2021-04-22 09:29:04 +00:00
cmdHead(config)
2021-04-22 10:38:52 +00:00
} else if config.Ls {
if !rexists["fs"] { log.Fatal("No fs folder found for repo ",config.RepoId) }
2021-04-23 10:18:38 +00:00
cmdLs(&config)
2021-04-22 10:38:52 +00:00
} else if config.Dump {
if !rexists["fs"] { log.Fatal("No fs folder found for repo ",config.RepoId) }
if !rexists["blocks"] { log.Fatal("No blocks folder found for repo ",config.RepoId) }
} else if config.S3 {
if !rexists["fs"] { log.Fatal("No fs folder found for repo ",config.RepoId) }
if !rexists["blocks"] { log.Fatal("No blocks folder found for repo ",config.RepoId) }
2021-04-21 12:44:49 +00:00
} else {
log.Fatal("This command is not implemented")
}
2021-04-21 12:25:35 +00:00
}