Compare commits

...

39 Commits

Author SHA1 Message Date
Alexander Neumann
c1f047bcc6 doc: Add paragraph about mkdocs 2016-02-21 13:08:10 +01:00
Alexander Neumann
f2b54348c4 doc: Add paragraph about documentation version 2016-02-21 13:08:10 +01:00
Alexander Neumann
fea113da98 Manual: Correct headings, add section about debug 2016-02-21 13:08:09 +01:00
Alexander Neumann
cbd77a7f61 Update manual 2016-02-21 13:08:09 +01:00
Alexander Neumann
f0790c134c Remove obsolete structure image 2016-02-21 13:08:09 +01:00
Alexander Neumann
385c73697d Add something to the front page 2016-02-21 13:08:08 +01:00
Alexander Neumann
f4a0fd299e Manual: Fix shell blocks and ToC 2016-02-21 13:07:40 +01:00
Alexander Neumann
fb5b90f308 Add mkdocs for readthedocs.org 2016-02-21 13:07:39 +01:00
Alexander Neumann
16e87d7208 add VERSION file for 0.1.0 2015-08-21 22:20:57 +02:00
Alexander Neumann
577a1bb232 Merge pull request #264 from restic/fix-124
WIP: cleanup readme
2015-08-21 22:19:14 +02:00
Florian Daniel
8b485c59fc Update README and Design documentation 2015-08-21 22:14:37 +02:00
Florian Daniel
34d7a674f8 cleanup readme 2015-08-21 22:12:12 +02:00
Alexander Neumann
228cafaab0 Remove warning, add note about compatibility 2015-08-21 22:00:12 +02:00
Alexander Neumann
fdbff14e78 Merge pull request #271 from restic/go1.5
travis: add go1.5
2015-08-20 20:58:33 +02:00
Alexander Neumann
fd2365724e Remove unneded variables 2015-08-20 19:45:04 +02:00
Alexander Neumann
9f7346354b CI: only run gox -build-toolchain for Go < 1.5 2015-08-20 19:42:40 +02:00
Alexander Neumann
94eebbaa88 travis: add go1.5 2015-08-20 19:21:53 +02:00
Alexander Neumann
d7426a72f4 Revert "travis: remove unneeded GOPATH definition from"
This reverts commit 3eac8061f9.
2015-08-20 19:21:35 +02:00
Alexander Neumann
864579404c Merge pull request #268 from restic/cross-compile-windows
CI: Add Windows
2015-08-20 19:11:46 +02:00
Alexander Neumann
3eac8061f9 travis: remove unneeded GOPATH definition from 2015-08-20 19:08:09 +02:00
Alexander Neumann
7ebf5397a3 clean up Makefile 2015-08-20 19:05:19 +02:00
Alexander Neumann
0cdbde1bd0 Remove unneeded comments 2015-08-20 18:54:24 +02:00
Alexander Neumann
4755fff37f README: Add appveyor build status 2015-08-19 22:20:44 +02:00
Alexander Neumann
2644722198 Reset read-only flag before removing 2015-08-19 22:02:47 +02:00
Alexander Neumann
10232155ef build.go: make sure to exit 1 on error 2015-08-19 21:40:36 +02:00
Alexander Neumann
5d51c8ffcd lock: fix merge error, use processExists() 2015-08-19 21:14:15 +02:00
Alexander Neumann
b8c0935f8a tests: use internal bzip2/gzip implementation 2015-08-19 21:00:17 +02:00
Alexander Neumann
7079e46642 appveyor: download tar 2015-08-19 21:00:11 +02:00
Alexander Neumann
d21b782119 appveyor: use run_integration_tests.go 2015-08-19 20:45:54 +02:00
Alexander Neumann
23845b071b integration: compile on current architecture by default 2015-08-19 20:44:37 +02:00
Alexander Neumann
527593c6df ci test: add message prefix 2015-08-19 20:29:06 +02:00
Alexander Neumann
5b21d67a49 lock_test: correct merge error, use offset 500k 2015-08-19 20:25:59 +02:00
Alexander Neumann
2df7ed6c9b fix brew cask on darwin 2015-08-19 20:24:53 +02:00
Alexander Neumann
f0c8b11793 cleanup travis config, add run_integration_tests.go 2015-08-19 20:24:52 +02:00
Alexander Neumann
59751645be build.go: allow running tests in temporary GOPATH 2015-08-19 20:24:52 +02:00
Alexander Neumann
a37431e963 appveyor: run build.go, use workspace from godeps 2015-08-19 20:23:52 +02:00
Alexander Neumann
b34c53d39b windows: fix nil pointer reference 2015-08-19 20:23:52 +02:00
Alexander Neumann
f2dbdcb9e8 Add appveyor config 2015-08-19 20:23:52 +02:00
Alexander Neumann
90d1414331 Cross-compile on windows 2015-08-19 20:23:52 +02:00
17 changed files with 705 additions and 975 deletions

View File

@@ -4,13 +4,12 @@ sudo: false
go:
- 1.3.3
- 1.4.2
- 1.5
os:
- linux
- osx
env: GOX_OS="linux darwin openbsd freebsd" GOX_ARCH="386 amd64 arm"
notifications:
irc:
channels:
@@ -25,22 +24,9 @@ install:
- export PATH="$PATH:$GOBIN"
- export GOPATH="$GOPATH:${TRAVIS_BUILD_DIR}/Godeps/_workspace"
- go env
- go get github.com/mattn/goveralls
- go get github.com/mitchellh/gox
- go version | grep -q "go1\.3" && export GOX_ARCH="386 amd64" || true
- go version | grep -q "darwin" && export GOX_OS="darwin" || true
- uname -s | grep -qi darwin && brew install caskroom/cask/brew-cask || true
- uname -s | grep -qi darwin && brew cask install osxfuse || true
- uname -s | grep -vqi darwin && export RESTIC_TEST_FUSE="0" || true
- echo "cross-compile for \"$GOX_OS\" on \"$GOX_ARCH\""
- gox -build-toolchain -os "$GOX_OS" -arch "$GOX_ARCH"
script:
- gox -verbose -os "$GOX_OS" -arch "$GOX_ARCH" -tags "release" ./cmd/restic
- gox -verbose -os "$GOX_OS" -arch "$GOX_ARCH" -tags "debug" ./cmd/restic
- go run build.go
- go run run_tests.go all.cov
- GOARCH=386 RESTIC_TEST_INTEGRATION=0 go test ./...
- go run run_integration_tests.go
after_success:
- goveralls -coverprofile=all.cov -service=travis-ci -repotoken "$COVERALLS_TOKEN" || true
- gofmt -l *.go */*.go */*/*.go
- test -z "$(gofmt -l *.go */*.go */*/*.go)"

View File

@@ -1,22 +1,12 @@
.PHONY: all clean test
SOURCE=$(wildcard *.go) $(wildcard */*.go) $(wildcard */*/*.go)
export GOPATH GOX_OS
all: restic
restic: $(SOURCE)
go run build.go
restic.debug: $(SOURCE)
go run build.go -tags debug
clean:
rm -rf restic restic.debug
rm -rf restic
test: $(SOURCE)
go run run_tests.go /dev/null
all.cov: $(SOURCE)
go run run_tests.go all.cov

View File

@@ -1,26 +1,22 @@
[![Stories in Ready](https://badge.waffle.io/restic/restic.png?label=ready&title=Ready)](https://waffle.io/restic/restic)
[![Build Status](https://travis-ci.org/restic/restic.svg?branch=master)](https://travis-ci.org/restic/restic)
[![Build status](https://ci.appveyor.com/api/projects/status/nuy4lfbgfbytw92q/branch/master?svg=true)](https://ci.appveyor.com/project/fd0/restic/branch/master)
[![sourcegraph status](https://sourcegraph.com/api/repos/github.com/restic/restic/.badges/status.png)](https://sourcegraph.com/github.com/restic/restic)
[![Coverage Status](https://coveralls.io/repos/restic/restic/badge.svg)](https://coveralls.io/r/restic/restic)
WARNING
=======
Restic Design Principles
========================
WARNING: At the moment, consider restic as alpha quality software, it is not
yet finished. Do not use it for real data!
Restic is a program that does backups right and was designed with the following
principles in mind:
Restic
======
Restic is a program that does backups right. The design goals are:
* Easy: Doing backups should be a frictionless process, otherwise you are
tempted to skip it. Restic should be easy to configure and use, so that in
the unlikely event of a data loss you can just restore it. Likewise,
* Easy: Doing backups should be a frictionless process, otherwise you might be
tempted to skip it. Restic should be easy to configure and use, so that, in
the event of a data loss, you can just restore it. Likewise,
restoring data should not be complicated.
* Fast: Backing up your data with restic should only be limited by your
network or harddisk bandwidth so that you can backup your files every day.
network or hard disk bandwidth so that you can backup your files every day.
Nobody does backups if it takes too much time. Restoring backups should only
transfer data that is needed for the files that are to be restored, so that
this process is also fast.
@@ -36,12 +32,12 @@ Restic is a program that does backups right. The design goals are:
* Efficient: With the growth of data, additional snapshots should only take
the storage of the actual increment. Even more, duplicate data should be
de-duplicated before it is actually written to the storage backend to save
de-duplicated before it is actually written to the storage back end to save
precious backup space.
Building
========
Build restic
============
Install Go/Golang (at least version 1.3), then run `go run build.go`,
afterwards you'll find the binary in the current directory:
@@ -76,20 +72,27 @@ afterwards you'll find the binary in the current directory:
A short demo recording can be found here:
[![asciicast](https://asciinema.org/a/23554.png)](https://asciinema.org/a/23554)
Compatibility
=============
Backward compatibility for backups is important so that our users are always
able to restore saved data. Therefore restic follows [Semantic
Versioning](http://semver.org) to clearly define which versions are compatible.
The repository and data structures contained therein are considered the "Public
API" in the sense of Semantic Versioning.
We guarantee backward compatibility of all repositories within one major version;
as long as we do not increment the major version, data can be read and restored.
We strive to be fully backward compatible to all prior versions.
Contribute and Documentation
============================
Contributions are welcome! More information can be found in
[`CONTRIBUTING.md`](CONTRIBUTING.md). A document describing the design of
restic and the data structures stored on disc is contained in
restic and the data structures stored on the backend is contained in
[`doc/Design.md`](doc/Design.md).
Development
===========
For development, please have a look at [`CONTRIBUTING.md`](CONTRIBUTING.md),
especially the section "Development Environment". If you have any questions,
please get in touch!
The development environment is described in [`CONTRIBUTING.md`](CONTRIBUTING.md).
Contact
=======

1
VERSION Normal file
View File

@@ -0,0 +1 @@
0.1.0

14
appveyor.yml Normal file
View File

@@ -0,0 +1,14 @@
clone_folder: c:\gopath\src\github.com\restic\restic
environment:
GOPATH: c:\gopath;c:\gopath\src\github.com\restic\restic\Godeps\_workspace
install:
- go version
- go env
- appveyor DownloadFile http://downloads.sourceforge.net/project/gnuwin32/tar/1.13-1/tar-1.13-1-bin.zip -FileName tar.zip
- 7z x tar.zip bin/tar.exe
- set PATH=bin/;%PATH%
build_script:
- go run run_integration_tests.go

View File

@@ -267,6 +267,12 @@ func (b *Local) Remove(t backend.Type, name string) error {
b.open[fn] = nil
b.mu.Unlock()
// reset read-only flag
err := os.Chmod(fn, 0666)
if err != nil {
return err
}
return os.Remove(fn)
}

View File

@@ -18,6 +18,7 @@ import (
var (
verbose bool
keepGopath bool
runTests bool
)
const timeFormat = "2006-01-02 15:04:05"
@@ -32,6 +33,21 @@ func specialDir(name string) bool {
return base[0] == '_' || base[0] == '.'
}
// excludePath returns true if the file should not be copied to the new GOPATH.
func excludePath(name string) bool {
ext := path.Ext(name)
if ext == ".go" || ext == ".s" {
return false
}
parentDir := filepath.Base(filepath.Dir(name))
if parentDir == "testdata" {
return false
}
return true
}
// updateGopath builds a valid GOPATH at dst, with all Go files in src/ copied
// to dst/prefix/, so calling
//
@@ -60,8 +76,7 @@ func updateGopath(dst, src, prefix string) error {
return nil
}
ext := path.Ext(name)
if ext != ".go" && ext != ".s" {
if excludePath(name) {
return nil
}
@@ -133,7 +148,10 @@ func showUsage(output io.Writer) {
fmt.Fprintf(output, "USAGE: go run build.go OPTIONS\n")
fmt.Fprintf(output, "\n")
fmt.Fprintf(output, "OPTIONS:\n")
fmt.Fprintf(output, " -v --verbose output more messages\n")
fmt.Fprintf(output, " -v --verbose output more messages\n")
fmt.Fprintf(output, " -t --tags specify additional build tags\n")
fmt.Fprintf(output, " -k --keep-gopath do not remove the GOPATH after build\n")
fmt.Fprintf(output, " -T --test run tests\n")
}
func verbosePrintf(message string, args ...interface{}) {
@@ -170,6 +188,18 @@ func build(gopath string, args ...string) error {
return cmd.Run()
}
// test runs "go test args..." with GOPATH set to gopath.
func test(gopath string, args ...string) error {
args = append([]string{"test"}, args...)
cmd := exec.Command("go", args...)
cmd.Env = append(cleanEnv(), "GOPATH="+gopath)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
verbosePrintf("go %s\n", args)
return cmd.Run()
}
// getVersion returns a version string, either from the file VERSION in the
// current directory or from git.
func getVersion() string {
@@ -218,6 +248,8 @@ func main() {
case "-t", "-tags", "--tags":
skipNext = true
buildTags = strings.Split(params[i+1], " ")
case "-T", "--test":
runTests = true
case "-h":
showUsage(os.Stdout)
default:
@@ -258,6 +290,17 @@ func main() {
die("copying files from %v to %v failed: %v\n", root, gopath, err)
}
defer func() {
if !keepGopath {
verbosePrintf("remove %v\n", gopath)
if err = os.RemoveAll(gopath); err != nil {
die("remove GOPATH at %s failed: %v\n", err)
}
} else {
fmt.Printf("leaving temporary GOPATH at %v\n", gopath)
}
}()
output := "restic"
if runtime.GOOS == "windows" {
output = "restic.exe"
@@ -276,15 +319,15 @@ func main() {
err = build(gopath, args...)
if err != nil {
fmt.Fprintf(os.Stderr, "build failed: %v\n", err)
die("build failed: %v\n", err)
}
if !keepGopath {
verbosePrintf("remove %v\n", gopath)
if err = os.RemoveAll(gopath); err != nil {
die("remove GOPATH at %s failed: %v\n", err)
if runTests {
verbosePrintf("running tests\n")
err = test(gopath, "github.com/restic/restic/...")
if err != nil {
die("running tests failed: %v\n", err)
}
} else {
fmt.Printf("leaving temporary GOPATH at %v\n", gopath)
}
}

View File

@@ -235,6 +235,8 @@ func getWindowsCacheDir() (string, error) {
if err != nil {
return "", err
}
return cachedir, nil
}
if err != nil {

View File

@@ -6,15 +6,15 @@ Terminology
This section introduces terminology used in this document.
*Repository*: All data produced during a backup is sent to and stored at a
repository in structured form, for example in a file system hierarchy of with
several subdirectories. A repository implementation must be able to fulfil a
*Repository*: All data produced during a backup is sent to and stored in a
repository in a structured form, for example in a file system hierarchy with
several subdirectories. A repository implementation must be able to fulfill a
number of operations, e.g. list the contents.
*Blob*: A Blob combines a number of data bytes with identifying information
like the SHA256 hash of the data and its length.
*Pack*: A Pack combines one or more Blobs together, e.g. in a single file.
*Pack*: A Pack combines one or more Blobs, e.g. in a single file.
*Snapshot*: A Snapshot stands for the state of a file or directory that has
been backed up at some point in time. The state here means the content and meta
@@ -22,7 +22,7 @@ data like the name and modification time for the file or the directory and its
contents.
*Storage ID*: A storage ID is the SHA-256 hash of the content stored in the
repository. This ID is needed in order to load the file from the repository.
repository. This ID is required in order to load the file from the repository.
Repository Format
=================
@@ -36,19 +36,20 @@ parallel. Only the delete operation removes data from the repository.
At the time of writing, the only implemented repository type is based on
directories and files. Such repositories can be accessed locally on the same
system or via the integrated SFTP client. The directory layout is the same for
both access methods. This repository type is described in the following.
system or via the integrated SFTP client (or any other storage back end).
The directory layout is the same for both access methods.
This repository type is described in the following section.
Repositories consist of several directories and a file called `config`. For
all other files stored in the repository, the name for the file is the lower
case hexadecimal representation of the storage ID, which is the SHA-256 hash of
the file's contents. This allows easily checking all files for accidental
modifications like disk read errors by simply running the program `sha256sum`
the file's contents. This allows for easy verification of files for accidental
modifications, like disk read errors, by simply running the program `sha256sum`
and comparing its output to the file name. If the prefix of a filename is
unique amongst all the other files in the same directory, the prefix may be
used instead of the complete filename.
Apart from the files stored below the `keys` directory, all files are encrypted
Apart from the files stored within the `keys` directory, all files are encrypted
with AES-256 in counter mode (CTR). The integrity of the encrypted data is
secured by a Poly1305-AES message authentication code (sometimes also referred
to as a "signature").
@@ -398,7 +399,7 @@ required to create a lock on the repository before doing anything.
Locks come in two types: Exclusive and non-exclusive locks. At most one
process can have an exclusive lock on the repository, and during that time
there mustn't be any other locks (exclusive and non-exclusive). There may be
there must not be any other locks (exclusive and non-exclusive). There may be
multiple non-exclusive locks in parallel.
A lock is a file in the subdir `locks` whose filename is the storage ID of

337
doc/Manual.md Normal file
View File

@@ -0,0 +1,337 @@
Thanks for using restic. This document will give you an overview of the basic
functionality provided by restic.
# Building/installing restic
If you are using Mac OS X, you can install restic using the
[homebrew](http://brew.sh/) packet manager:
$ brew tap restic/restic
$ brew install restic
On archlinux, there is a package called `restic-git` which can be installed from AUR, e.g. with `pacaur`:
$ pacaur -S restic-git
If you are using Linux, BSD or Windows, the only way to install restic on your
system right now is to compile it from source. restic is written in the Go
programming language and you need at least Go version 1.3. See the [Getting
started](https://golang.org/doc/install) guide of the Go project for
instructions how to install Go.
In order to build restic from source, execute the following steps:
$ git clone https://github.com/restic/restic
[...]
$ cd restic
$ go run build.go
Usage help is available:
$ ./restic --help
Usage:
restic [OPTIONS] <command>
Application Options:
-r, --repo= Repository directory to backup to/restore from
Help Options:
-h, --help Show this help message
Available commands:
backup save file/directory
cache manage cache
cat dump something
find find a file/directory
fsck check the repository
init create repository
key manage keys
list lists data
ls list files
restore restore a snapshot
snapshots show snapshots
version display version
Similar to programs such as `git`, restic has a number of sub-commands. You can
see these commands in the listing above. Each sub-command may have own
command-line options, and there is a help option for each command which lists
them, e.g. for the `backup` command:
$ ./restic backup --help
Usage:
restic [OPTIONS] backup DIR/FILE [DIR/FILE] [...]
The backup command creates a snapshot of a file or directory
Application Options:
-r, --repo= Repository directory to backup to/restore from
--cache-dir= Directory to use as a local cache
-q, --quiet Do not output comprehensive progress report (false)
--no-lock Do not lock the repo, this allows some operations on read-only repos. (false)
Help Options:
-h, --help Show this help message
[backup command options]
-p, --parent= use this parent snapshot (default: last snapshot in repo that has the same target)
-f, --force Force re-reading the target. Overrides the "parent" flag
-e, --exclude= Exclude a pattern (can be specified multiple times)
# Initialize a repository
First, we need to create a "repository". This is the place where your backups
will be saved at.
In order to create a repository at `/tmp/backup`, run the following command and
enter the same password twice:
$ restic init --repo /tmp/backup
enter password for new backend:
enter password again:
created restic backend 085b3c76b9 at /tmp/backup
Please note that knowledge of your password is required to access the repository.
Losing your password means that your data is irrecoverably lost.
Remembering your password is important! If you lose it, you won't be able to
access data stored in the repository.
For automated backups, restic accepts the repository location in the
environment variable `RESTIC_REPOSITORY` and also the password in the variable
`RESTIC_PASSWORD`.
## Password prompt on Windows
At the moment, restic only supports the default Windows console interaction.
If you use emulation environments like [MSYS2](https://msys2.github.io/) or
[Cygwin](https://www.cygwin.com/), which use terminals like `Mintty` or `rxvt`,
you may get a password error:
You can workaround this by using a special tool called `winpty` (look
[here](https://sourceforge.net/p/msys2/wiki/Porting/) and
[here](https://github.com/rprichard/winpty) for detail information). On MSYS2,
you can install `winpty` as follows:
$ pacman -S winpty
$ winpty restic -r /tmp/backup init
# Create a snapshot
Now we're ready to backup some data. The contents of a directory at a specific
point in time is called a "snapshot" in restic. Run the following command and
enter the repository password you chose above again:
$ restic -r /tmp/backup backup ~/work
enter password for repository:
scan [/home/user/work]
scanned 764 directories, 1816 files in 0:00
[0:29] 100.00% 54.732 MiB/s 1.582 GiB / 1.582 GiB 2580 / 2580 items 0 errors ETA 0:00
duration: 0:29, 54.47MiB/s
snapshot 40dc1520 saved
As you can see, restic created a backup of the directory and was pretty fast!
The specific snapshot just created is identified by a sequence of hexadecimal
characters, `40dc1520` in this case.
If you run the command again, restic will create another snapshot of your data,
but this time it's even faster. This is de-duplication at work!
$ restic -r /tmp/backup backup ~/shared/work/web
enter password for repository:
using parent snapshot 40dc1520aa6a07b7b3ae561786770a01951245d2367241e71e9485f18ae8228c
scan [/home/user/work]
scanned 764 directories, 1816 files in 0:00
[0:00] 100.00% 0B/s 1.582 GiB / 1.582 GiB 2580 / 2580 items 0 errors ETA 0:00
duration: 0:00, 6572.38MiB/s
snapshot 79766175 saved
You can even backup individual files in the same repository.
$ restic -r /tmp/backup backup ~/work.txt
scan [~/work.txt]
scanned 0 directories, 1 files in 0:00
[0:00] 100.00% 0B/s 220B / 220B 1 / 1 items 0 errors ETA 0:00
duration: 0:00, 0.03MiB/s
snapshot 31f7bd63 saved
In fact several hosts may use the same repository to backup directories and
files leading to a greater de-duplication.
# List all snapshots
Now, you can list all the snapshots stored in the repository:
$ restic -r /tmp/backup snapshots
enter password for repository:
ID Date Source Directory
----------------------------------------------------------------------
40dc1520 2015-05-08 21:38:30 kasimir /home/user/work
79766175 2015-05-08 21:40:19 kasimir /home/user/work
# Restore a snapshot
Restoring a snapshot is as easy as it sounds, just use the following command to
restore the contents of the latest snapshot to `/tmp/restore-work`:
$ restic -r /tmp/backup restore 79766175 --target ~/tmp/restore-work
enter password for repository:
restoring <Snapshot of [/home/user/work] at 2015-05-08 21:40:19.884408621 +0200 CEST> to /tmp/restore-work
# Manage repository keys
The `key` command allows you to set multiple access keys or passwords per
repository. In fact, you can use the `list`, `add`, `remove` and `passwd`
sub-commands to manage these keys very precisely:
$ restic -r /tmp/backup key list
enter password for repository:
ID User Host Created
----------------------------------------------------------------------
*eb78040b username kasimir 2015-08-12 13:29:57
$ restic -r /tmp/backup key add
enter password for repository:
enter password for new key:
enter password again:
saved new key as <Key of username@kasimir, created on 2015-08-12 13:35:05.316831933 +0200 CEST>
$ restic -r backup key list
enter password for repository:
ID User Host Created
----------------------------------------------------------------------
5c657874 username kasimir 2015-08-12 13:35:05
*eb78040b username kasimir 2015-08-12 13:29:57
# Check integrity and consistency
Imagine your repository is saved on a server that has a faulty hard drive, or
even worse, attackers get privileged access and modify your backup with the
intention to make you restore malicious data:
$ sudo echo "boom" >> backup/index/d795ffa99a8ab8f8e42cec1f814df4e48b8f49129360fb57613df93739faee97
In order to detect these things, it is a good idea to regularly use the `check`
command to test whether everything is alright, your precious backup data is
consistent and the integrity is unharmed:
$ restic -r /tmp/backup check
Load indexes
ciphertext verification failed
Trying to restore a snapshot which has been modified as shown above will yield
the same error:
$ restic -r /tmp/backup restore 79766175 --target ~/tmp/restore-work
Load indexes
ciphertext verification failed
# Mount a repository
Browsing your backup as a regular file system is also very easy. First, create
a mount point such as `/mnt/restic` and then use the following command to serve
the repository with FUSE:
$ mkdir /mnt/restic
$ restic -r /tmp/backup mount /mnt/restic
enter password for repository:
Now serving /tmp/backup at /tmp/restic
Don't forget to umount after quitting!
Windows doesn't support FUSE directly. Projects like
[dokan](http://dokan-dev.github.io/) try to fill the gap. We haven't tested it
yet, but we'd like to hear about your experience. For setup information see
[dokan FUSE in dokan's wiki](https://github.com/dokan-dev/dokany/wiki/FUSE).
# Create an SFTP repository
In order to backup data via SFTP, you must first set up a server with SSH and
let it know your public key. Passwordless login is really important since
restic fails to connect to the repository if the server prompts for
credentials.
Once the server is configured, the setup of the SFTP repository can simply be
achieved by changing the URL scheme in the `init` command:
$ restic -r sftp://user@host//tmp/backup init
enter password for new backend:
enter password again:
created restic backend f1c6108821 at sftp://user@host//tmp/backup
Please note that knowledge of your password is required to access the repository.
Losing your password means that your data is irrecoverably lost.
Yes, that's really two slash (`/`) characters after the host name, here the
directory `/tmp/backup` on the server is meant. If you'd rather like to create
a repository in the user's home directory on the server, use the location
`sftp://user@host/foo/bar/repo`. In this case the directory is relative to the
user's home directory: `foo/bar/repo`.
# Create an Amazon S3 repository
Restic can backup data to any Amazon S3 bucket. However, in this case, changing the URL scheme is not enough since Amazon uses special security credentials to sign HTTP requests. By consequence, you must first setup the following environment variables with the credentials you obtained while creating the bucket.
$ export AWS_ACCESS_KEY_ID=<MY_ACCESS_KEY>
$ export AWS_SECRET_ACCESS_KEY=<MY_SECRET_ACCESS_KEY>
You can then easily initialize a repository that uses your Amazon S3 as a backend.
$ restic -r s3://s3.amazonaws.com/bucket_name init
enter password for new backend:
enter password again:
created restic backend eefee03bbd at s3://s3.amazonaws.com/bucket_name
Please note that knowledge of your password is required to access the repository.
Losing your password means that your data is irrecoverably lost.
For an S3-compatible repository without TLS available, use the alternative URI
protocol `s3:http://server:port/bucket_name`.
# Debugging restic
The program can be built with debug support like this:
$ go run build.go -tags debug
Afterwards, extensive debug messages are written to the file in environment
variable `RESTIC_DEBUG`, e.g.:
$ RESTIC_DEBUG=/tmp/restic-debug.log restic backup ~/work
If you suspect that there is a bug, you can have a look at the debug log.
Please be aware that the debug log might contain sensitive information such as
file and directory names.
# Under the hood: Browse repository objects
Internally, a repository stores data of several different types described in the [design documentation](https://github.com/restic/restic/blob/master/doc/Design.md). You can `list` objects such as blobs, packs, index, snapshots, keys or locks with the following command:
```shell
$ restic -r /tmp/backup list snapshots
d369ccc7d126594950bf74f0a348d5d98d9e99f3215082eb69bf02dc9b3e464c
```
The `find` command searches for a given
[pattern](http://golang.org/pkg/path/filepath/#Match) in the repository.
$ restic -r backup find test.txt
debug log file restic.log
debug enabled
enter password for repository:
found 1 matching entries in snapshot 196bc5760c909a7681647949e80e5448e276521489558525680acf1bd428af36
-rw-r--r-- 501 20 5 2015-08-26 14:09:57 +0200 CEST path/to/test.txt
The `cat` command allows you to display the JSON representation of the objects
or its raw content.
$ restic -r /tmp/backup cat snapshot d369ccc7d126594950bf74f0a348d5d98d9e99f3215082eb69bf02dc9b3e464c
enter password for repository:
{
"time": "2015-08-12T12:52:44.091448856+02:00",
"tree": "05cec17e8d3349f402576d02576a2971fc0d9f9776ce2f441c7010849c4ff5af",
"paths": [
"/home/user/work"
],
"hostname": "kasimir",
"username": "username",
"uid": 501,
"gid": 20
}

25
doc/index.md Normal file
View File

@@ -0,0 +1,25 @@
Welcome to restic
=================
![restic logo](logo/logo.svg)
restic is a backup program that is fast, efficient and secure. On the left you
can find an overview of the documentation. The project's homepage is
<https://restic.github.io>, the source code repository can be found on GitHub
at the URL <https://github.com/restic/restic>.
The documentation you're currently viewing may not match the version of restic
you have installed. If you cloned the repository manually, you can find the
right documentation in the directory `doc/`. If you're viewing this online at
<https://restic.readthedocs.org>, there is a small menu at the bottom left of
this page, where you can select the version.
The restic documentation is built with [MkDocs](http://www.mkdocs.org). After
installing it, you can edit and view the documentation locally by running:
$ mkdocs serve
INFO - Building documentation...
INFO - Cleaning site directory
[I 160221 12:33:57 server:271] Serving on http://127.0.0.1:8000
Afterwards visit the URL with a browser.

View File

@@ -1,884 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="210mm"
height="297mm"
id="svg4198"
version="1.1"
inkscape:version="0.48.5 r10040"
sodipodi:docname="structure.svg">
<defs
id="defs3">
<marker
inkscape:stockid="Arrow2Mend"
orient="auto"
refY="0.0"
refX="0.0"
id="Arrow2Mend"
style="overflow:visible;">
<path
id="path5383"
style="fill-rule:evenodd;stroke-width:0.62500000;stroke-linejoin:round;"
d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.9730900,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z "
transform="scale(0.6) rotate(180) translate(0,0)" />
</marker>
<marker
inkscape:stockid="Arrow2Lend"
orient="auto"
refY="0.0"
refX="0.0"
id="Arrow2Lend"
style="overflow:visible;">
<path
id="path5377"
style="fill-rule:evenodd;stroke-width:0.62500000;stroke-linejoin:round;"
d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.9730900,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z "
transform="scale(1.1) rotate(180) translate(1,0)" />
</marker>
</defs>
<sodipodi:namedview
inkscape:document-units="mm"
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="1.3810888"
inkscape:cx="278.75145"
inkscape:cy="788.04056"
inkscape:current-layer="layer1"
showgrid="true"
units="mm"
inkscape:window-width="1362"
inkscape:window-height="729"
inkscape:window-x="0"
inkscape:window-y="18"
inkscape:window-maximized="0"
inkscape:snap-grids="false"
inkscape:snap-to-guides="true">
<inkscape:grid
type="xygrid"
id="grid4204"
empspacing="10"
visible="true"
enabled="true"
snapvisiblegridlinesonly="true"
dotted="false"
spacingx="1mm"
spacingy="1mm"
units="mm" />
</sodipodi:namedview>
<metadata
id="metadata4">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<rect
rx="3.5432446"
ry="3.5432444"
y="125.31244"
x="337.60443"
height="8.6873627"
width="31.788435"
id="rect5239-1"
style="fill:#ccff99;fill-opacity:1;stroke:#000000;stroke-width:0.99921262;stroke-miterlimit:4;stroke-opacity:0;stroke-dasharray:none" />
<rect
rx="3.5432446"
ry="3.5432444"
y="450.72906"
x="266.07547"
height="8.6873627"
width="31.788435"
id="rect5342"
style="fill:#fdd99b;fill-opacity:1;stroke:#000000;stroke-width:0.99921262;stroke-miterlimit:4;stroke-opacity:0;stroke-dasharray:none" />
<rect
style="fill:#986601;fill-opacity:1;stroke:#000000;stroke-width:0.99921262;stroke-miterlimit:4;stroke-opacity:0;stroke-dasharray:none"
id="rect5344"
width="31.788435"
height="8.6873627"
x="270.97147"
y="460.72906"
ry="3.5432444"
rx="3.5432446" />
<rect
style="fill:#ccff99;fill-opacity:1;stroke:#000000;stroke-width:0.99921262;stroke-miterlimit:4;stroke-opacity:0;stroke-dasharray:none"
id="rect5324"
width="31.788435"
height="8.6873627"
x="270.67154"
y="430.52609"
ry="3.5432444"
rx="3.5432446" />
<rect
rx="3.5432446"
ry="3.5432444"
y="420.34509"
x="265.94748"
height="8.6873627"
width="31.788435"
id="rect5326"
style="fill:#339900;fill-opacity:1;stroke:#000000;stroke-width:0.99921262;stroke-miterlimit:4;stroke-opacity:0;stroke-dasharray:none" />
<rect
style="fill:#fdd99b;fill-opacity:1;stroke:#000000;stroke-width:0.99921262;stroke-miterlimit:4;stroke-opacity:0;stroke-dasharray:none"
id="rect5303"
width="31.788435"
height="8.6873627"
x="265.94748"
y="390.34506"
ry="3.5432444"
rx="3.5432446" />
<rect
rx="3.5432446"
ry="3.5432444"
y="400.34506"
x="270.84348"
height="8.6873627"
width="31.788435"
id="rect5301"
style="fill:#986601;fill-opacity:1;stroke:#000000;stroke-width:0.99921262;stroke-miterlimit:4;stroke-opacity:0;stroke-dasharray:none" />
<text
xml:space="preserve"
style="font-size:10px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
x="88.58268"
y="184.25194"
id="text3797"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan3799"
x="88.58268"
y="184.25194"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Monospace;-inkscape-font-specification:Monospace">data/</tspan></text>
<text
xml:space="preserve"
style="font-size:10px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
x="88.58268"
y="77.952728"
id="text3801"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan3803"
x="88.58268"
y="77.952728"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Monospace;-inkscape-font-specification:Monospace">keys/</tspan></text>
<text
xml:space="preserve"
style="font-size:10px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
x="88.58268"
y="113.3858"
id="text3809"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan3811"
x="88.58268"
y="113.3858"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Monospace;-inkscape-font-specification:Monospace">snapshots/</tspan></text>
<text
xml:space="preserve"
style="font-size:10px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
x="88.58268"
y="276.37793"
id="text3813"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan3815"
x="88.58268"
y="276.37793"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Monospace;-inkscape-font-specification:Monospace">trees/</tspan></text>
<text
xml:space="preserve"
style="font-size:10px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
x="88.58268"
y="148.81886"
id="text3817"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan3819"
x="88.58268"
y="148.81886"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Monospace;-inkscape-font-specification:Monospace">maps/</tspan></text>
<rect
rx="3.5432444"
ry="3.5432444"
y="120.47243"
x="99.212608"
height="14.17323"
width="42.519684"
id="rect3840"
style="fill:#f0a513;fill-opacity:1;stroke:#000000;stroke-opacity:0" />
<text
sodipodi:linespacing="125%"
id="text3842"
y="131.10234"
x="102.75592"
style="font-size:10px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
xml:space="preserve"><tspan
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Monospace;-inkscape-font-specification:Monospace"
y="131.10234"
x="102.75592"
id="tspan3844"
sodipodi:role="line">6e4065</tspan></text>
<rect
style="fill:#aaccee;fill-opacity:1;stroke:#000000;stroke-opacity:0"
id="rect3864"
width="42.519684"
height="14.17323"
x="99.212608"
y="155.9055"
ry="3.5432444"
rx="3.5432444" />
<text
xml:space="preserve"
style="font-size:10px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
x="102.75592"
y="166.53545"
id="text3866"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan3868"
x="102.75592"
y="166.53545"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Monospace;-inkscape-font-specification:Monospace">b35a97</tspan></text>
<rect
rx="3.5432444"
ry="3.5432444"
y="201.96844"
x="120.47243"
height="14.17323"
width="42.519684"
id="rect3880"
style="fill:#986601;fill-opacity:1;stroke:#000000;stroke-opacity:0" />
<text
sodipodi:linespacing="125%"
id="text3882"
y="212.59839"
x="124.01575"
style="font-size:10px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
xml:space="preserve"><tspan
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Monospace;-inkscape-font-specification:Monospace"
y="212.59839"
x="124.01575"
id="tspan3884"
sodipodi:role="line">1bde93</tspan></text>
<text
xml:space="preserve"
style="font-size:10px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
x="109.84253"
y="198.42513"
id="text3964"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan3966"
x="109.84253"
y="198.42513"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Monospace;-inkscape-font-specification:Monospace">1b/</tspan></text>
<rect
style="fill:#986601;fill-opacity:1;stroke:#000000;stroke-opacity:0"
id="rect3975"
width="42.519684"
height="14.17323"
x="120.47243"
y="230.31494"
ry="3.5432444"
rx="3.5432444" />
<text
xml:space="preserve"
style="font-size:10px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
x="124.01574"
y="240.94489"
id="text3977"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan3979"
x="124.01574"
y="240.94489"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Monospace;-inkscape-font-specification:Monospace">47808f</tspan></text>
<text
sodipodi:linespacing="125%"
id="text3981"
y="226.77159"
x="109.84253"
style="font-size:10px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
xml:space="preserve"><tspan
y="226.77159"
x="109.84253"
id="tspan3983"
sodipodi:role="line"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Monospace;-inkscape-font-specification:Monospace">47/</tspan></text>
<rect
rx="3.5432444"
ry="3.5432444"
y="248.03148"
x="120.47245"
height="14.17323"
width="42.519684"
id="rect3987"
style="fill:#986601;fill-opacity:1;stroke:#000000;stroke-opacity:0" />
<text
sodipodi:linespacing="125%"
id="text3989"
y="258.66144"
x="124.01575"
style="font-size:10px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
xml:space="preserve"><tspan
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Monospace;-inkscape-font-specification:Monospace"
y="258.66144"
x="124.01575"
id="tspan3991"
sodipodi:role="line">47853a</tspan></text>
<rect
style="fill:#ccff99;fill-opacity:1;stroke:#000000;stroke-opacity:0"
id="rect4039"
width="42.519684"
height="14.17323"
x="120.47243"
y="294.09445"
ry="3.5432444"
rx="3.5432444" />
<text
xml:space="preserve"
style="font-size:10px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
x="124.01575"
y="304.7244"
id="text4041"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan4043"
x="124.01575"
y="304.7244"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Monospace;-inkscape-font-specification:Monospace">967de5</tspan></text>
<text
sodipodi:linespacing="125%"
id="text4045"
y="290.55115"
x="109.84253"
style="font-size:10px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
xml:space="preserve"><tspan
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Monospace;-inkscape-font-specification:Monospace"
y="290.55115"
x="109.84253"
id="tspan4047"
sodipodi:role="line">9f/</tspan></text>
<rect
rx="3.5432444"
ry="3.5432444"
y="322.44095"
x="120.47243"
height="14.17323"
width="42.519684"
id="rect4051"
style="fill:#ccff99;fill-opacity:1;stroke:#000000;stroke-opacity:0" />
<text
sodipodi:linespacing="125%"
id="text4053"
y="333.07089"
x="124.01574"
style="font-size:10px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
xml:space="preserve"><tspan
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Monospace;-inkscape-font-specification:Monospace"
y="333.07089"
x="124.01574"
id="tspan4055"
sodipodi:role="line">a0c69f</tspan></text>
<text
xml:space="preserve"
style="font-size:10px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
x="109.84253"
y="318.89764"
id="text4057"
sodipodi:linespacing="125%"><tspan
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Monospace;-inkscape-font-specification:Monospace"
sodipodi:role="line"
id="tspan4059"
x="109.84253"
y="318.89764">a0/</tspan></text>
<rect
style="fill:#ccff99;fill-opacity:1;stroke:#000000;stroke-opacity:0"
id="rect4063"
width="42.519684"
height="14.17323"
x="120.47243"
y="350.78732"
ry="3.5432444"
rx="3.5432444" />
<text
xml:space="preserve"
style="font-size:10px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
x="124.01575"
y="361.41727"
id="text4065"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan4067"
x="124.01575"
y="361.41727"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Monospace;-inkscape-font-specification:Monospace">beb505</tspan></text>
<text
sodipodi:linespacing="125%"
id="text4069"
y="347.24402"
x="109.84253"
style="font-size:10px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
xml:space="preserve"><tspan
y="347.24402"
x="109.84253"
id="tspan4071"
sodipodi:role="line"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Monospace;-inkscape-font-specification:Monospace">be/</tspan></text>
<g
id="g4085"
transform="translate(53.149608,-372.04724)">
<path
transform="translate(0,308.26769)"
inkscape:connector-curvature="0"
id="path4073"
d="m 24.80315,131.10236 0,7.08661 7.086614,0"
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<path
transform="translate(0,308.26769)"
inkscape:connector-curvature="0"
id="path4075"
d="m 24.80315,138.18897 0,35.43307 7.086614,0"
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<path
transform="translate(0,308.26769)"
inkscape:connector-curvature="0"
id="path4079"
d="m 24.80315,173.62204 c 0.262467,0.51087 0.262467,0.51087 0,0 l 0,35.43307 7.086614,0"
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<path
transform="translate(0,308.26769)"
inkscape:connector-curvature="0"
id="path4081"
d="m 24.80315,209.05511 0,35.43307 7.086614,0"
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<path
transform="translate(0,308.26769)"
inkscape:connector-curvature="0"
id="path4083"
d="m 24.80315,244.48818 0,92.12599 7.086614,0"
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
</g>
<path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 99.212598,187.79524 0,7.08661 7.086612,0"
id="path4116"
inkscape:connector-curvature="0" />
<path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 99.212598,194.88186 0,28.34646 7.086612,0"
id="path4118"
inkscape:connector-curvature="0" />
<path
style="fill:none;stroke:#000000;stroke-width:0.99999994px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 99.212597,279.92123 0,7.08662 7.086613,0"
id="path4120"
inkscape:connector-curvature="0" />
<path
style="fill:none;stroke:#000000;stroke-width:0.99999994px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 99.212597,287.00785 0,28.34646 7.086613,0"
id="path4122"
inkscape:connector-curvature="0" />
<path
style="fill:none;stroke:#000000;stroke-width:0.99999994px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 99.212597,315.35431 0,28.34645 7.086613,0"
id="path4126"
inkscape:connector-curvature="0" />
<text
sodipodi:linespacing="125%"
id="text4128"
y="375.59052"
x="88.58268"
style="font-size:10px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
xml:space="preserve"><tspan
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Monospace;-inkscape-font-specification:Monospace"
y="375.59052"
x="88.58268"
id="tspan4130"
sodipodi:role="line">tmp/</tspan></text>
<text
xml:space="preserve"
style="font-size:10px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
x="88.58268"
y="389.76376"
id="text4132"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan4134"
x="88.58268"
y="389.76376"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Monospace;-inkscape-font-specification:Monospace">locks/</tspan></text>
<path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 77.952758,272.83462 0,99.2126 7.08661,0"
id="path4140"
inkscape:connector-curvature="0" />
<path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 77.952758,372.04722 0,14.17322 7.08661,0"
id="path4144"
inkscape:connector-curvature="0" />
<path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 77.952758,386.22044 0,14.17323 7.08661,0"
id="path4146"
inkscape:connector-curvature="0" />
<text
sodipodi:linespacing="125%"
id="text4156"
y="403.93698"
x="88.58268"
style="font-size:10px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
xml:space="preserve"><tspan
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Monospace;-inkscape-font-specification:Monospace"
y="403.93698"
x="88.58268"
id="tspan4158"
sodipodi:role="line">version</tspan></text>
<g
id="g4485"
transform="translate(-17.71652,7.0866626)">
<rect
style="fill:#ffeeaa;fill-opacity:1;stroke:none"
id="rect7169"
width="42.519684"
height="14.17323"
x="116.92913"
y="77.95269"
ry="3.5432444"
rx="3.5432444" />
<text
xml:space="preserve"
style="font-size:10px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
x="120.47243"
y="88.582603"
id="text7171"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan7173"
x="120.47243"
y="88.582603"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Monospace;-inkscape-font-specification:Monospace">c913e0</tspan></text>
</g>
<rect
style="fill:#339900;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-opacity:0"
id="rect4607"
width="31.404444"
height="8.6214886"
x="276.1517"
y="124.92723"
ry="3.5432446"
rx="3.5432446" />
<text
xml:space="preserve"
style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Monaco;-inkscape-font-specification:Monaco"
x="219.68503"
y="92.125961"
id="text4528"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
x="219.68503"
y="92.125961"
id="tspan4552"
style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Monospace;-inkscape-font-specification:Monospace">{time: 2015-01-01T13:12:13.40,</tspan><tspan
sodipodi:role="line"
x="219.68503"
y="102.12596"
id="tspan4538"
style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Monospace;-inkscape-font-specification:Monospace"> dir: /data,</tspan><tspan
sodipodi:role="line"
x="219.68503"
y="112.12596"
id="tspan4540"
style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Monospace;-inkscape-font-specification:Monospace"> hostname: kasimir,</tspan><tspan
sodipodi:role="line"
x="219.68503"
y="122.12596"
id="tspan4542"
style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Monospace;-inkscape-font-specification:Monospace"> username: hans,</tspan><tspan
sodipodi:role="line"
x="219.68503"
y="132.12596"
id="tspan4546"
style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Monospace;-inkscape-font-specification:Monospace"> tree: {id: 486f6c, sid: 967de5},</tspan><tspan
sodipodi:role="line"
x="219.68503"
y="142.12596"
id="tspan4556"
style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Monospace;-inkscape-font-specification:Monospace"> [...]</tspan><tspan
sodipodi:role="line"
x="219.68503"
y="152.12596"
id="tspan4560"
style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Monospace;-inkscape-font-specification:Monospace">}</tspan></text>
<rect
style="fill:#f0a513;fill-opacity:1;stroke:#000000;stroke-width:0.99999988;stroke-opacity:0"
id="rect4519"
width="177.16533"
height="21.259836"
x="212.59842"
y="60.236198"
ry="3.5432441"
rx="3.5432444" />
<rect
style="fill:none;stroke:#000000;stroke-width:1.77165354;stroke-miterlimit:2;stroke-opacity:1;stroke-dasharray:none"
id="rect4511"
width="177.16534"
height="106.29922"
x="212.59839"
y="60.236198"
rx="3.5432441"
ry="3.5432444" />
<text
xml:space="preserve"
style="font-size:10px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
x="219.68501"
y="74.409424"
id="text4513"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan4515"
x="219.68501"
y="74.409424">snapshot</tspan></text>
<text
xml:space="preserve"
style="font-size:10px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
x="272.83466"
y="74.409424"
id="text4521"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan4523"
x="272.83466"
y="74.409424"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Monospace;-inkscape-font-specification:Monospace">6e4065</tspan></text>
<text
xml:space="preserve"
style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Monospace;-inkscape-font-specification:Monospace"
x="432.28345"
y="92.125946"
id="text5187"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
x="432.28345"
y="92.125946"
id="tspan5216" /></text>
<rect
style="fill:#339900;fill-opacity:1;stroke:#000000;stroke-width:0.99921262;stroke-miterlimit:4;stroke-opacity:0;stroke-dasharray:none"
id="rect5328"
width="31.788435"
height="8.6873627"
x="290.65253"
y="290.55115"
ry="3.5432444"
rx="3.5432446" />
<rect
style="fill:#fdd99b;fill-opacity:1;stroke:#000000;stroke-width:0.99921262;stroke-miterlimit:4;stroke-opacity:0;stroke-dasharray:none"
id="rect5316"
width="31.788435"
height="8.6873627"
x="333.17938"
y="350.39966"
ry="3.5432444"
rx="3.5432446" />
<rect
rx="3.5432446"
ry="3.5432444"
y="350.5314"
x="294.73447"
height="8.6873627"
width="31.788435"
id="rect5314"
style="fill:#fdd99b;fill-opacity:1;stroke:#000000;stroke-width:0.99921262;stroke-miterlimit:4;stroke-opacity:0;stroke-dasharray:none" />
<rect
rx="3.5432439"
ry="3.5432444"
y="201.96848"
x="212.5984"
height="21.259878"
width="212.59843"
id="rect5259"
style="fill:#339900;fill-opacity:1;stroke:#000000;stroke-width:0.99921262;stroke-miterlimit:4;stroke-opacity:0;stroke-dasharray:none" />
<rect
style="fill:none;stroke:#000000;stroke-width:1.77165353;stroke-miterlimit:2;stroke-opacity:1;stroke-dasharray:none"
id="rect5253"
width="212.59843"
height="294.09451"
x="212.59842"
y="201.96849"
rx="3.5432439"
ry="3.5432451" />
<text
xml:space="preserve"
style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Monospace;-inkscape-font-specification:Monospace"
x="219.68504"
y="216.14169"
id="text5255"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan5257"
x="219.68504"
y="216.14169"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Sans;-inkscape-font-specification:Sans">tree</tspan></text>
<text
xml:space="preserve"
style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Monospace;-inkscape-font-specification:Monospace"
x="248.03149"
y="216.14169"
id="text5261"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan5263"
x="248.03149"
y="216.14169">486f6c</tspan></text>
<text
xml:space="preserve"
style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Monospace;-inkscape-font-specification:Monospace"
x="219.68504"
y="237.40155"
id="text5265"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
x="219.68504"
y="237.40155"
id="tspan5269">{ nodes: [</tspan><tspan
sodipodi:role="line"
x="219.68504"
y="247.40155"
id="tspan3211"> {</tspan><tspan
sodipodi:role="line"
x="219.68504"
y="257.40155"
id="tspan3241"> name: testdir1,</tspan><tspan
sodipodi:role="line"
x="219.68504"
y="267.40155"
id="tspan5271"> type: dir,</tspan><tspan
sodipodi:role="line"
x="219.68504"
y="277.40155"
id="tspan5273"> mode: 0755,</tspan><tspan
sodipodi:role="line"
x="219.68504"
y="287.40155"
id="tspan5275"> user: hans,</tspan><tspan
sodipodi:role="line"
x="219.68504"
y="297.40155"
id="tspan5281"> subtree: a8838f}</tspan><tspan
sodipodi:role="line"
x="219.68504"
y="307.40155"
id="tspan5283"> },{</tspan><tspan
sodipodi:role="line"
x="219.68504"
y="317.40155"
id="tspan3239"> name: testfile,</tspan><tspan
sodipodi:role="line"
x="219.68504"
y="327.40155"
id="tspan5285"> type: file,</tspan><tspan
sodipodi:role="line"
x="219.68504"
y="337.40155"
id="tspan5287"> mode: 0640,</tspan><tspan
sodipodi:role="line"
x="219.68504"
y="347.40155"
id="tspan5289"> user: hans,</tspan><tspan
sodipodi:role="line"
x="219.68504"
y="357.40155"
id="tspan5291"> content: [50f77b, ea0cc4, [...]]</tspan><tspan
sodipodi:role="line"
x="219.68504"
y="367.40155"
id="tspan3251"> }],</tspan><tspan
sodipodi:role="line"
x="219.68504"
y="377.40155"
id="tspan3255"> map:[</tspan><tspan
sodipodi:role="line"
x="219.68504"
y="387.40155"
id="tspan3496"> {</tspan><tspan
sodipodi:role="line"
x="219.68504"
y="397.40155"
id="tspan3522"> id: 50f77b,</tspan><tspan
sodipodi:role="line"
x="219.68504"
y="407.40155"
id="tspan3498"> sid: 1bde93</tspan><tspan
sodipodi:role="line"
x="219.68504"
y="417.40155"
id="tspan3500"> },{</tspan><tspan
sodipodi:role="line"
x="219.68504"
y="427.40155"
id="tspan3502"> id: a8838f,</tspan><tspan
sodipodi:role="line"
x="219.68504"
y="437.40155"
id="tspan3504"> sid: a0c69f</tspan><tspan
sodipodi:role="line"
x="219.68504"
y="447.40155"
id="tspan3506"> },{</tspan><tspan
sodipodi:role="line"
x="219.68504"
y="457.40155"
id="tspan3508"> id: ea0cc4,</tspan><tspan
sodipodi:role="line"
x="219.68504"
y="467.40155"
id="tspan3510"> sid: 47853a</tspan><tspan
sodipodi:role="line"
x="219.68504"
y="477.40155"
id="tspan3512"> }, [...]</tspan><tspan
sodipodi:role="line"
x="219.68504"
y="487.40155"
id="tspan3514">]}</tspan></text>
<path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow2Lend)"
d="m 301.18111,170.07873 0,28.34645"
id="path6665"
inkscape:connector-curvature="0" />
<rect
style="fill:none;stroke:#000000;stroke-width:1.77165354;stroke-miterlimit:2;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
id="rect4052"
width="102.75591"
height="350.78741"
x="70.866142"
y="60.236198"
rx="3.5432441"
ry="3.5432446" />
<path
style="fill:none;stroke:#000000;stroke-width:0.9992126;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none;marker-end:url(#Arrow2Lend)"
d="M 148.8189,127.55903 209.05512,70.86612"
id="path4834"
inkscape:connector-curvature="0" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 36 KiB

15
lock.go
View File

@@ -207,17 +207,10 @@ func (l *Lock) Stale() bool {
return false
}
proc, err := os.FindProcess(l.PID)
defer proc.Release()
if err != nil {
debug.Log("Lock.Stale", "error searching for process %d: %v\n", l.PID, err)
return true
}
debug.Log("Lock.Stale", "sending SIGHUP to process %d\n", l.PID)
err = proc.Signal(syscall.SIGHUP)
if err != nil {
debug.Log("Lock.Stale", "signal error: %v, lock is probably stale\n", err)
// check if we can reach the process retaining the lock
exists := l.processExists()
if !exists {
debug.Log("Lock.Stale", "could not reach process, %d, lock is probably stale\n", l.PID)
return true
}

View File

@@ -134,7 +134,7 @@ var staleLockTests = []struct {
timestamp: time.Now(),
stale: true,
staleOnOtherHost: false,
pid: os.Getpid() + 500,
pid: os.Getpid() + 500000,
},
}
@@ -204,7 +204,7 @@ func TestRemoveAllLocks(t *testing.T) {
id2, err := createFakeLock(repo, time.Now().Add(-time.Minute), os.Getpid())
OK(t, err)
id3, err := createFakeLock(repo, time.Now().Add(-time.Minute), os.Getpid()+500)
id3, err := createFakeLock(repo, time.Now().Add(-time.Minute), os.Getpid()+500000)
OK(t, err)
OK(t, restic.RemoveAllLocks(repo))

7
mkdocs.yml Normal file
View File

@@ -0,0 +1,7 @@
site_name: Documentation for restic
theme: readthedocs
docs_dir: doc
pages:
- Getting Started: index.md
- User Manual: Manual.md
- restic Design Document: Design.md

189
run_integration_tests.go Normal file
View File

@@ -0,0 +1,189 @@
// +build ignore
package main
import (
"fmt"
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
)
type CIEnvironment interface {
Prepare()
RunTests()
}
type TravisEnvironment struct {
goxArch []string
goxOS []string
}
func (env *TravisEnvironment) Prepare() {
msg("preparing environment for Travis CI\n")
run("go", "get", "github.com/mattn/goveralls")
run("go", "get", "github.com/mitchellh/gox")
if runtime.GOOS == "darwin" {
// install the libraries necessary for fuse
run("brew", "install", "caskroom/cask/brew-cask")
run("brew", "cask", "install", "osxfuse")
}
// only test cross compilation on linux with Travis
if runtime.GOOS == "linux" {
env.goxArch = []string{"386", "amd64"}
if !strings.HasPrefix(runtime.Version(), "go1.3") {
env.goxArch = append(env.goxArch, "arm")
}
env.goxOS = []string{"linux", "darwin", "freebsd", "openbsd", "windows"}
} else {
env.goxArch = []string{runtime.GOARCH}
env.goxOS = []string{runtime.GOOS}
}
msg("gox: OS %v, ARCH %v\n", env.goxOS, env.goxArch)
if !strings.HasPrefix(runtime.Version(), "go1.5") {
run("gox", "-build-toolchain",
"-os", strings.Join(env.goxOS, " "),
"-arch", strings.Join(env.goxArch, " "))
}
}
func (env *TravisEnvironment) RunTests() {
// run fuse tests on darwin
if runtime.GOOS != "darwin" {
msg("skip fuse integration tests on %v\n", runtime.GOOS)
os.Setenv("RESTIC_TEST_FUSE", "0")
}
// compile for all target architectures with tags
for _, tags := range []string{"release", "debug"} {
run("gox", "-verbose",
"-os", strings.Join(env.goxOS, " "),
"-arch", strings.Join(env.goxArch, " "),
"-tags", tags,
"./cmd/restic")
}
// run the build script
run("go", "run", "build.go")
// gather coverage information
run("go", "run", "run_tests.go", "all.cov")
runGofmt()
}
type AppveyorEnvironment struct{}
func (env *AppveyorEnvironment) Prepare() {
msg("preparing environment for Appveyor CI\n")
}
func (env *AppveyorEnvironment) RunTests() {
run("go", "run", "build.go", "-v", "-T")
}
// findGoFiles returns a list of go source code file names below dir.
func findGoFiles(dir string) (list []string, err error) {
err = filepath.Walk(dir, func(name string, fi os.FileInfo, err error) error {
if filepath.Base(name) == "Godeps" {
return filepath.SkipDir
}
if filepath.Ext(name) == ".go" {
relpath, err := filepath.Rel(dir, name)
if err != nil {
return err
}
list = append(list, relpath)
}
return err
})
return list, err
}
func msg(format string, args ...interface{}) {
fmt.Printf("CI: "+format, args...)
}
func runGofmt() {
dir, err := os.Getwd()
if err != nil {
fmt.Fprintf(os.Stderr, "Getwd(): %v\n", err)
os.Exit(5)
}
files, err := findGoFiles(dir)
if err != nil {
fmt.Fprintf(os.Stderr, "error finding Go files: %v\n", err)
os.Exit(4)
}
msg("runGofmt() with %d files\n", len(files))
args := append([]string{"-l"}, files...)
cmd := exec.Command("gofmt", args...)
cmd.Stderr = os.Stderr
buf, err := cmd.Output()
if err != nil {
fmt.Fprintf(os.Stderr, "error running gofmt: %v", err)
fmt.Fprintf(os.Stderr, "output:\n%s\n", buf)
os.Exit(3)
}
if len(buf) > 0 {
fmt.Fprintf(os.Stderr, "not formatted with `gofmt`:\n")
fmt.Fprintln(os.Stderr, string(buf))
os.Exit(6)
}
}
func run(command string, args ...string) {
msg("run %v %v\n", command, strings.Join(args, " "))
cmd := exec.Command(command, args...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
err := cmd.Run()
if err != nil {
fmt.Fprintf(os.Stderr, "error running %v %v: %v",
command, strings.Join(args, " "), err)
os.Exit(3)
}
}
func isTravis() bool {
return os.Getenv("TRAVIS_BUILD_DIR") != ""
}
func isAppveyor() bool {
return runtime.GOOS == "windows"
}
func main() {
var env CIEnvironment
switch {
case isTravis():
env = &TravisEnvironment{}
case isAppveyor():
env = &AppveyorEnvironment{}
default:
fmt.Fprintln(os.Stderr, "unknown CI environment")
os.Exit(1)
}
for _, f := range []func(){env.Prepare, env.RunTests} {
f()
}
}

View File

@@ -2,7 +2,10 @@ package test_helper
import (
"bytes"
"compress/bzip2"
"compress/gzip"
"fmt"
"io"
"io/ioutil"
"math/rand"
"os"
@@ -89,14 +92,28 @@ func RandomReader(seed, size int) *bytes.Reader {
// SetupTarTestFixture extracts the tarFile to outputDir.
func SetupTarTestFixture(t testing.TB, outputDir, tarFile string) {
f, err := os.Open(tarFile)
defer f.Close()
input, err := os.Open(tarFile)
defer input.Close()
OK(t, err)
cmd := exec.Command("tar", "xzf", "-")
var rd io.Reader
switch filepath.Ext(tarFile) {
case ".gz":
r, err := gzip.NewReader(input)
OK(t, err)
defer r.Close()
rd = r
case ".bzip2":
rd = bzip2.NewReader(input)
default:
rd = input
}
cmd := exec.Command("tar", "xf", "-")
cmd.Dir = outputDir
cmd.Stdin = f
cmd.Stdin = rd
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr