Commit Graph

137 Commits

Author SHA1 Message Date
Michael Eischer 655430550b Extract parameters for second repository from copy command 2020-09-19 16:07:55 +02:00
greatroar 9abef3bf1a Move internal/fs.TestChdir to internal/test.Chdir 2020-09-17 10:43:33 +02:00
Michael Eischer c0fc85d303 diff: Add integration test 2020-09-13 16:28:46 +02:00
Michael Eischer b22655367c integration_test: Replace fprintf without format string 2020-09-05 10:07:16 +02:00
Michael Eischer 068a3ce23f Remove redundant return 2020-09-05 10:07:16 +02:00
Michael Eischer d19f05c960 Use buf.String() instead of string(buf.Bytes()) 2020-09-05 10:07:16 +02:00
Michael Eischer 460e2ffbf6 Collapse a few boolean operations 2020-09-05 10:07:14 +02:00
Michael Eischer 2f8335554c Remove a few unused variables 2020-09-05 10:06:23 +02:00
Michael Eischer 9a4796594a integration tests: Fix checking of wrong snapshot 2020-08-29 10:48:44 +02:00
Michael Eischer 15374d22e9 integration tests: Add basic tests for copy command 2020-08-29 10:48:44 +02:00
Michael Eischer 88ad58d6cd integration tests: Redirect directory diff into intermediate buffer 2020-08-29 10:48:44 +02:00
Michael Eischer 591a8c4cdf integration tests: Deduplicate backup test-data setup code 2020-08-29 10:48:44 +02:00
Michael Eischer 08d24ff99e prune: Include ID of all missing blobs in error message 2020-08-16 11:36:14 +02:00
Michael Eischer 1c84aceb39 prune: Test for abort on damaged repositories 2020-08-16 11:36:12 +02:00
Michael Eischer 575ed9a47e Test that rebuild-index errors when old index cannot be removed 2020-08-16 11:34:01 +02:00
aawsome 0fed6a8dfc
Use "pack file" instead of "data file" (#2885)
- changed variable names, especially changed DataFile into PackFile
- changed in some comments
- always use "pack file" in docu
2020-08-16 11:16:38 +02:00
Alexander Neumann 2580eef2aa
Merge pull request #2318 from classmarkets/2175-named-keys
Allow specifying user and host when adding keys
2020-08-01 13:06:31 +02:00
Michael Eischer 3ce9893e0b Don't print a stacktrace if some files could not be read 2020-07-28 23:52:48 +02:00
Alexander Weiss 9175795fdb Check contents in archiver
When backing up with a parent snapshot and the file is not changed, also
check if contents are still available in index.
2020-07-25 08:18:28 +02:00
David Sommer 5729d967f5 backup: Return exit status code 3 when failing to read source data
The backup command used to return a zero exit code as long as a snapshot
could be created successfully, even if some of the source files could not
be read (in which case the snapshot would contain the rest of the files).

This made it hard for automation/scripts to detect failures/incomplete
backups by looking at the exit code. Restic now returns the following exit
codes for the backup command:

 - 0 when the command was successful
 - 1 when there was a fatal error (no snapshot created)
 - 3 when some source data could not be read (incomplete snapshot created)
2020-07-20 22:19:01 +02:00
Peter Schultz 90fc639a67 Allow specifying user and host when adding keys
The username and hostname for new keys can be specified with the new
--user and --host flags, respectively. The flags are used only by the
`key add` command and are otherwise ignored.

This allows adding keys with for a desired user and host without having
to run restic as that particular user on that particular host, making
automated key management easier.

Co-authored-by: James TD Smith <ahktenzero@mohorovi.cc>
2020-03-23 13:11:10 +01:00
Alexander Weiss 9a9101d144 Support specifying multiple host flags for various commands
The `dump`, `find`, `forget`, `ls`, `mount`, `restore`, `snapshots`,
`stats` and `tag` commands will now take into account multiple
`--host` and `-H` flags.
2020-02-26 22:17:59 +01:00
David Brown d9e22c2df1 Add test for `--json` support for `forget` command
This adds a test of the json output of the forget command, by running it
once, asking it to keep one snapshot, and verifying that the output has
the right number of snapshots listed in the Keep and Remove fields of
the result.
2019-02-22 22:00:20 -07:00
Igor Fedorenko 5fa6dc53cb Refactor: introduced restorer tree visitor
Signed-off-by: Igor Fedorenko <igor@ifedorenko.com>
2018-06-11 07:57:22 -04:00
Alexander Neumann 321efec60c Fix integration tests on Windows 2018-06-10 00:00:22 +02:00
Alexander Neumann 8d9d218d1c list: Improve error message
Before:

    $ restic list
    Fatal: type not specified

After:

    $ restic list
    Fatal: type not specified, usage: list [blobs|packs|index|snapshots|keys|locks]

Closes #1783
2018-05-17 19:41:56 +02:00
Alexander Neumann fca4fe4459 backup: Disable status output for --quiet 2018-05-02 21:24:18 +02:00
Alexander Neumann 0e78ac92d8 Use new archiver code for backup 2018-04-28 22:08:11 +02:00
Alexander Neumann a5c0cf2324 Add workaround for symlinked temp dir on darwin
Chdir to the tempdir, then use os.Getwd() to get the name that
filepath.Abs() uses (and stores in the Snapshot).
2018-04-25 14:42:45 +02:00
Alexander Neumann 38926d8576 Use new archiver code in tests 2018-04-25 14:42:45 +02:00
Alexander Neumann b804279fe8 integration tests: Don't print anything to stdout 2018-04-22 11:37:05 +02:00
Alexander Neumann 4544a77172 Slightly increment size for TestIncrementalBackup
This should make the test more reliable, it should hit the accidental
"repo is has grown too much" way less often.
2018-04-01 13:49:42 +02:00
Bowen Song 34671d7c9b Skip archiver.Scan before backup when --quiet is set 2018-03-20 20:44:10 +00:00
Alexander Neumann dfb6d0fced Reduce data for TestIncrementalBackup 2018-03-11 21:17:27 +01:00
Alexander Neumann c6c1dccc53 Reduce data set for TestRestore 2018-03-11 21:10:37 +01:00
Alexander Neumann 279566bafe Reduce dataset for integration tests 2018-03-11 21:07:47 +01:00
Alexander Neumann c67a8452f7 Disable polynomial check for chunker for tests 2018-03-11 20:59:40 +01:00
Felix Lee 7b44fd0f9d fix #1143
Backup was choosing a parent snapshot that had the same tags, which
makes backup unnecessarily slow when there are newer snapshots with
different tags.

There's no reason parent has to have the same tags.

This change makes backup choose the newest snapshot instead.
2017-10-05 11:48:26 -07:00
Herbert 033589a66b Use rtest on these as well to keep codebase consistent 2017-10-02 17:48:08 +02:00
Herbert 3473c3f7b6 Remove all dot-imports 2017-10-02 15:06:39 +02:00
Ricardo Seriani 62ed776a8c Change key rm command to key remove
Change key rm command to key remove, to follow manual and other commands
2017-08-17 11:03:26 -03:00
Alexander Neumann d780b1eede Rework withTestEnvironment
Switch from a function passed as a parameter to a cleanup function,
which is also executed when the test function panics, so no temporary
directories are left behind.
2017-07-24 21:32:34 +02:00
Alexander Neumann 23c903074c Move restic package to internal/restic 2017-07-24 17:43:32 +02:00
Alexander Neumann 94b27e8933 Fix paths for tests 2017-07-23 14:39:57 +02:00
Alexander Neumann 6caeff2408 Run goimports 2017-07-23 14:21:03 +02:00
Alexander Neumann 83d1a46526 Moves files 2017-07-23 14:19:13 +02:00
Alexander Neumann b63399d606 Move things around for gb
This moves all restic source files to src/, and all vendored
dependencies to vendor/src.
2016-02-20 17:31:20 +01:00
Alexander Neumann a1440c819b Make NoLock a global option 2015-11-13 12:33:59 +01:00
Alexander Neumann 6edb7e02d0 Allow restoring and listing without locking 2015-11-10 22:13:53 +01:00
Alexander Neumann c79dcbd7c4 Allow checking a read-only repo with --no-lock 2015-11-10 21:41:22 +01:00
Alexander Neumann acba82c8f7 Merge pull request #252 from restic/repack-blobs
WIP: Repack blobs
2015-11-09 20:57:57 +01:00
Alexander Neumann 1f9aea9905 fix test on windows, reset read-only flag 2015-11-08 22:41:45 +01:00
Alexander Neumann 742d69bf4d Add another test for optimizing unused blobs 2015-11-08 22:38:17 +01:00
Alexander Neumann 5776b8f01c remove ConvertIndex 2015-11-08 22:27:13 +01:00
Alexander Neumann 2e6eee991d Add test for optimize command with old indexes 2015-11-08 22:21:08 +01:00
Alexander Neumann c4fc7b52ae Add 'optimize' command that repacks blobs 2015-11-08 21:10:03 +01:00
Alexander Neumann ea41a1045f Add integration test for error on readdirnames 2015-11-06 23:19:56 +01:00
Alexander Neumann 734ae7fcb8 Add test for corner case
It was observed that a restic repository still contained overlapping
indexes after `rebuild-index` has been called. This is caused by
instantly forgetting that blobs have already been saved once a full
index has been written during index rebuilding.

This commit adds a (failing) test that shows the behaviour.
2015-10-25 21:51:57 +01:00
Alexander Neumann 7b8e42a763 Silence rebuild-index tests 2015-10-25 21:51:46 +01:00
Alexander Neumann 6aed9f268b Add command `rebuild-index` 2015-10-25 17:24:52 +01:00
Chapuis Bertil c765688779 find command integration tests 2015-08-28 19:31:05 +02:00
Alexander Neumann 5cdcc99eba Use array instead of hash for backend.ID
Since backend.ID is always a slice of constant length, use an array
instead of a slice. Mostly, arrays behave as slices, except that an
array cannot be nil, so use `*backend.ID` insteaf of `backend.ID` in
places where the absence of an ID is possible (e.g. for the Subtree of a
Node, which may not present when the node is a file node).

This change allows to directly use backend.ID as the the key for a map,
so that arbitrary data structures (e.g. a Set implemented as a
map[backend.ID]struct{}) can easily be formed.
2015-07-25 18:01:57 +02:00
Alexander Neumann deaca157fe restore: ignore errors
Also add a test for restoring a file that is owned by root. Closes #244.
2015-07-25 12:59:59 +02:00
Alexander Neumann cc34401152 Record exclude patterns in snapshot
This adds the exclude patterns used to create a backup in the snapshot,
so we can later compute statistics (like git does) on the data
structure, e.g. added/removed files etc. For that, we need the exclude
pattern.
2015-07-22 22:43:32 +02:00
Alexander Neumann 1da89253cf Add include filter for restore
Include and exclude filter are mutually exclusive.
2015-07-20 19:21:01 +02:00
Alexander Neumann c0337a2675 Add exclude filter to restorer and 'restore' command 2015-07-20 19:21:01 +02:00
Alexander Neumann 7fd52f9f57 Add exclude filter to archiver and 'backup' command 2015-07-20 19:21:01 +02:00
Alexander Neumann 54c4c29a89 Add checker and command 'check' to replace 'fsck' 2015-07-11 16:27:38 +02:00
Alexander Neumann 389ec9b101 Add tests for restore filter 2015-07-09 20:12:31 +02:00
Alexander Neumann 5ae04b6834 Add last integration tests, remove testsuite 2015-06-21 17:40:22 +02:00
Alexander Neumann 43d4558a90 Add test for backing up non-existing directories 2015-06-21 17:40:22 +02:00
Alexander Neumann cfaf8ab8a6 Add integration test for key handling 2015-06-21 17:40:22 +02:00
Alexander Neumann a99a460b32 Fix integration tests 2015-06-21 17:40:22 +02:00
Alexander Neumann 4388474cdc Restructure `cmd/restic`, no functional changes 2015-06-21 17:40:22 +02:00
Alexander Neumann 2fa259816b rename `opts` to `mainOpts` 2015-06-21 17:40:22 +02:00
Alexander Neumann 1216ded14b Add integration test for key command 2015-06-21 17:40:22 +02:00
Alexander Neumann e2563b3eca Fix comments 2015-06-21 17:40:22 +02:00
Alexander Neumann a176b1b5a6 Add more integration tests 2015-06-21 17:40:22 +02:00
Alexander Neumann 9853fbcf48 Remove more flags from tests 2015-06-21 17:40:21 +02:00
Alexander Neumann 3a65f27c3f Automatically find fixtures for integration test 2015-06-21 17:40:21 +02:00
Alexander Neumann 030f08a410 Remove flags from tests 2015-06-21 17:40:21 +02:00
Alexander Neumann d8d09b6d69 Fix restic configuration for integration tests 2015-06-21 17:40:21 +02:00
Alexander Neumann 12677b4f8a Use flag instead of build tag to run integration tests 2015-06-21 17:40:21 +02:00
Alexander Neumann 7c107acf0b More integration tests 2015-06-21 17:40:21 +02:00
Alexander Neumann 954025e399 Add integration test with the go testing framework 2015-06-21 17:40:21 +02:00
Alexander Neumann 848793df84 Remove unused file 2015-06-07 18:13:22 +02:00
Alexander Neumann cd4c56b927 wip 2015-05-09 13:54:47 +02:00