Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

59 lines (47 sloc) 1.202 kb
package main
import (
var backupFlags = flag.NewFlagSet("backup", flag.ExitOnError)
var backupWait = backupFlags.Bool("w", false, "Wait for backup to complete")
type Backup struct {
Filename string
OID string
When time.Time
Conf cbfsconfig.CBFSConfig
func backupCommand(ustr string, args []string) {
u := cbfstool.ParseURL(ustr)
fn := backupFlags.Arg(0)
u.Path = "/.cbfs/backup/"
form := url.Values{
"fn": []string{fn},
"bg": []string{strconv.FormatBool(*backupWait == false)},
start := time.Now()
res, err := http.Post(u.String(),
cbfstool.MaybeFatal(err, "Error executing POST to %v - %v", u, err)
defer res.Body.Close()
if !(res.StatusCode == 202 || res.StatusCode == 201) {
log.Printf("backup error: %v", res.Status)
io.Copy(os.Stderr, res.Body)
if *backupWait {
log.Printf("Completed backup to %v in %v", fn, time.Since(start))
} else {
log.Printf("Submitted backup task for %v", fn)
Jump to Line
Something went wrong with that request. Please try again.