19070: Still trying to fix test_with_arvbox
[arvados.git] / doc / admin / keep-recovering-data.html.textile.liquid
1 ---
2 layout: default
3 navsection: admin
4 title: "Recovering data"
5 ...
6
7 {% comment %}
8 Copyright (C) The Arvados Authors. All rights reserved.
9
10 SPDX-License-Identifier: CC-BY-SA-3.0
11 {% endcomment %}
12
13 Arvados has several features to prevent accidental loss or deletion of data, but accidents can happen. This page lays out the options to recover deleted or overwritten collections.
14
15 For more detail on the data lifecycle in Arvados, see the "Data lifecycle":{{ site.baseurl }}/architecture/keep-data-lifecycle.html page.
16
17 h2(#check_the_trash). Check the trash
18
19 When a collection is deleted, it is moved to the trash. It will remain there for the duration of @Collections.DefaultTrashLifetime@, and it can be untrashed via workbench or with the cli tools, as described in "Recovering trashed collections":{{ site.baseurl }}/user/tutorials/tutorial-keep-collection-lifecycle.html#trash-recovery.
20
21 h2(#check_other_collections). Check for other collections with the same PDH
22
23 Multiple collections may share a _portable data hash_, i.e. have the same contents. If another collection exists with the same portable data hash, recovering data is not necessary, everything is still stored in Keep. A new copy of the collection can be made to make the data available in the correct project and with the correct permissions.
24
25 h2(#check_collection_versioning). Consider collection versioning
26
27 Arvados supports collection versioning. If it has not been "disabled":{{ site.baseurl }}/admin/collection-versioning.html on your cluster, the deleted collection may be recoverable from an older version. See "Using collection versioning":{{ site.baseurl }}/user/topics/collection-versioning.html for details.
28
29 h2(#recover_collection). Recovering collections
30
31 When all the above options fail, it may still be possible to recover a collection that has been deleted.
32
33 To recover a collection the manifest is required. Arvados has a built-in audit log, which consists of a row added to the "logs" table in the PostgreSQL database each time an Arvados object is created, modified, or deleted. Collection manifests are included, unless they are listed in the @AuditLogs.UnloggedAttributes@ configuration parameter. The audit log is retained for up to @AuditLogs.MaxAge@.
34
35 In some cases, it is possible to recover files that have been lost by modifying or deleting a collection.
36
37 Possibility of recovery depends on many factors, including:
38 * Whether the collection manifest is still available, e.g., in an audit log entry
39 * Whether the data blocks are also referenced by other collections
40 * Whether the data blocks have been unreferenced long enough to be marked for deletion/trash by keep-balance
41 * Blob signature TTL, trash lifetime, trash check interval, and other config settings
42
43 To attempt recovery of a previous version of a deleted/modified collection, use the @arvados-server recover-collection@ command. It should be run on one of your server nodes where the @arvados-server@ package is installed and the @/etc/arvados/config.yml@ file is up to date.
44
45 Specify the collection you want to recover by passing either the UUID of an audit log entry, or a file containing the manifest.
46
47 If recovery is successful, the @recover-collection@ program saves the recovered data a new collection belonging to the system user, and prints the new collection's UUID on stdout.
48
49 <pre>
50 # arvados-server recover-collection 9tee4-57u5n-nb5awmk1pahac2t
51 INFO[2020-06-05T19:52:29.557761245Z] loaded log entry                              logged_event_time="2020-06-05 16:48:01.438791 +0000 UTC" logged_event_type=update old_collection_uuid=9tee4-4zz18-1ex26g95epmgw5w src=9tee4-57u5n-nb5awmk1pahac2t
52 INFO[2020-06-05T19:52:29.642145127Z] recovery succeeded                            UUID=9tee4-4zz18-5trfp4k4xxg97f1 src=9tee4-57u5n-nb5awmk1pahac2t
53 9tee4-4zz18-5trfp4k4xxg97f1
54 INFO[2020-06-05T19:52:29.644699436Z] exiting
55 </pre>
56
57 In this example, the original data has been restored and saved in a new collection with UUID @9tee4-4zz18-5trfp4k4xxg97f1@.
58
59 For more options, run @arvados-server recover-collection -help@.
60
61 h2(#untrashing_lost_blocks). Untrashing lost blocks
62
63 In some cases it is possible to recover data blocks that were trashed erroneously by @keep-balance@ (e.g. due to an install/config error).
64
65 If you suspect blocks have been trashed erroneously, you should immediately:
66
67 * On all keepstore servers: set @BlobTrashCheckInterval@ to a long time like 2400h
68 * On all keepstore servers: restart keepstore
69 * Stop the keep-balance service
70
71 When you think you have corrected the underlying problem, you should:
72
73 * Set @Collections.BlobMissingReport@ to a suitable value (perhaps "/tmp/keep-balance-lost-blocks.txt").
74 * Start @keep-balance@
75 * After @keep-balance@ completes its first sweep, inspect /tmp/keep-balance-lost-blocks.txt. If it's not empty, you can request all keepstores to untrash any blocks that are still recoverable with a script like this:
76
77 <notextile>
78 <pre><code>
79 #!/bin/bash
80 set -e
81
82 # see Client.AuthToken in /etc/arvados/keep-balance/keep-balance.yml
83 token=xxxxxxx-your-system-auth-token-xxxxxxx
84
85 # all keep server hostnames
86 hosts=(keep0 keep1 keep2 keep3 keep4 keep5)
87
88 while read hash pdhs; do
89   echo "${hash}"
90   for h in ${hosts[@]}; do
91     if curl -fgs -H "Authorization: Bearer $token" -X PUT "http://${h}:25107/untrash/$hash"; then
92       echo "${hash} ok ${host}"
93     fi
94   done
95 done < /tmp/keep-balance-lost-blocks.txt
96 </code>
97 </pre>
98 </notextile>
99
100 Any blocks which were successfully untrashed can be removed from the list of blocks and collections which need to be recovered.
101
102 h2(#regenerating_lost_blocks). Regenerating lost blocks
103
104 For blocks which were trashed long enough ago that they've been deleted, it may be possible to regenerate them by rerunning the workflows which generated them. To do this, the process is:
105
106 * Delete the affected collections so that job reuse doesn't attempt to reuse them (it's likely that if one block is missing, they all are, so they're unlikely to contain any useful data)
107 * Resubmit any container requests for which you want the output collections regenerated
108
109 The Arvados repository contains a tool that can be used to generate a report to help with this task at "arvados/tools/keep-xref/keep-xref.py":https://github.com/arvados/arvados/blob/main/tools/keep-xref/keep-xref.py