Re wrote backup in go

Previously backup was a cmd plugin writen in bash.
Backup was implemented as a go function, still not in use.
Tests where added since the previous implementation had none.
backup package includes:
 * BackUp function, which performs the actual back up.
 * tarFiles which creates a tar or tar.gz/tgz depending
on the output file name given.
 * runCommand which is a convenience function to simplify testing
since the back up process requires calling external executable
mongoexport.
Iirc it's because I had to add a closure there as the walkfn and it looked
more cluttered than this way.

On Friday, June 13, 2014, Andrew Wilkins <notifications@github.com> wrote:

> In state/backup/backup.go:
>
> > +		return err
> > +	}
> > +	h, err := tar.FileInfoHeader(fInfo, "")
> > +	if err != nil {
> > +		return fmt.Errorf("cannot create tar header for %q: %v", fileName, err)
> > +	}
> > +	h.Name = strings.TrimPrefix(fileName, strip)
> > +	h.Name = strings.TrimPrefix(h.Name, string(os.PathSeparator))
> > +	if err := tarw.WriteHeader(h); err != nil {
> > +		return fmt.Errorf("cannot write header for %q: %v", fileName, err)
> > +	}
> > +	if fInfo.IsDir() {
> > +		if !strings.HasSuffix(fileName, string(os.PathSeparator)) {
> > +			fileName = fileName + string(os.PathSeparator)
> > +		}
> > +		directoryChildren, err := filepath.Glob(fileName + "*")
>
> Any particular reason why you don't just use path/filepath.Walk
> <http://godoc.org/path/filepath#Walk>?
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/juju/juju/pull/79/files#r13738871>.
>