code: func CreateBackup(dir, backupsDir string, limit int) error {
  	tmpBackupDir := filepath.Join(backupsDir, "tmp")
  	if err := os.MkdirAll(backupsDir, 0750); err != nil {
  		return err
  	}
  	if err := fileutil.CopyTree(dir, tmpBackupDir, user.NewBlankUidRange()); err != nil {
  		return err
  	}
  	defer os.RemoveAll(tmpBackupDir)
  	// prune backups
  	if err := pruneOldBackups(backupsDir, limit-1); err != nil {
  		return err
  	}
  	if err := shiftBackups(backupsDir, limit-2); err != nil {
  		return err
  	}
  	if err := os.Rename(tmpBackupDir, filepath.Join(backupsDir, "0")); err != nil {
  		return err
  	}
  	return nil
  }
docs: // CreateBackup backs a directory up in a given directory. It basically
  // copies this directory into a given backups directory. The backups
  // directory has a simple structure - a directory inside named "0" is
  // the most recent backup. A directory name for oldest backup is
  // deduced from a given limit. For instance, for limit being 5 the
  // name for the oldest backup would be "4". If a backups number
  // exceeds the given limit then only newest ones are kept and the rest
  // is removed.