mirror of
https://github.com/borgbackup/borg.git
synced 2025-03-04 02:28:34 +00:00
list: files->items, clarifications
This commit is contained in:
parent
7cce650a38
commit
abb0a20d4f
3 changed files with 15 additions and 16 deletions
|
@ -42,7 +42,7 @@ archive_progress
|
||||||
|
|
||||||
progress_message
|
progress_message
|
||||||
A message-based progress information with no concrete progress information, just a message
|
A message-based progress information with no concrete progress information, just a message
|
||||||
saying what is currently worked on.
|
saying what is currently being worked on.
|
||||||
|
|
||||||
operation
|
operation
|
||||||
unique, opaque integer ID of the operation
|
unique, opaque integer ID of the operation
|
||||||
|
@ -209,7 +209,7 @@ array under the *archives* key, while :ref:`borg_create` returns a single archiv
|
||||||
Both formats contain a *name* key with the archive name, the *id* key with the hexadecimal archive ID,
|
Both formats contain a *name* key with the archive name, the *id* key with the hexadecimal archive ID,
|
||||||
and the *start* key with the start timestamp.
|
and the *start* key with the start timestamp.
|
||||||
|
|
||||||
info and create further have:
|
*borg info* and *borg create* further have:
|
||||||
|
|
||||||
end
|
end
|
||||||
End timestamp
|
End timestamp
|
||||||
|
@ -250,11 +250,8 @@ Example of a simple archive listing (``borg list --last 1 --json``)::
|
||||||
{
|
{
|
||||||
"archives": [
|
"archives": [
|
||||||
{
|
{
|
||||||
"archive": "2017-02-27T21:21:51",
|
|
||||||
"barchive": "2017-02-27T21:21:51",
|
|
||||||
"id": "80cd07219ad725b3c5f665c1dcf119435c4dee1647a560ecac30f8d40221a46a",
|
"id": "80cd07219ad725b3c5f665c1dcf119435c4dee1647a560ecac30f8d40221a46a",
|
||||||
"name": "2017-02-27T21:21:51",
|
"name": "host-system-backup-2017-02-27",
|
||||||
"time": "Mon, 2017-02-27 21:21:52",
|
|
||||||
"start": "Mon, 2017-02-27 21:21:52"
|
"start": "Mon, 2017-02-27 21:21:52"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -287,7 +284,7 @@ The same archive with more information (``borg info --last 1 --json``)::
|
||||||
"limits": {
|
"limits": {
|
||||||
"max_archive_size": 0.0001330855110409714
|
"max_archive_size": 0.0001330855110409714
|
||||||
},
|
},
|
||||||
"name": "2017-02-27T21:21:51",
|
"name": "host-system-backup-2017-02-27",
|
||||||
"start": "Mon, 2017-02-27 21:21:52",
|
"start": "Mon, 2017-02-27 21:21:52",
|
||||||
"stats": {
|
"stats": {
|
||||||
"compressed_size": 1880961894,
|
"compressed_size": 1880961894,
|
||||||
|
@ -322,7 +319,7 @@ The same archive with more information (``borg info --last 1 --json``)::
|
||||||
.. rubric:: File listings
|
.. rubric:: File listings
|
||||||
|
|
||||||
Listing the contents of an archive can produce *a lot* of JSON. Each item (file, directory, ...) is described
|
Listing the contents of an archive can produce *a lot* of JSON. Each item (file, directory, ...) is described
|
||||||
by one object in the *files* array of the :ref:`borg_list` output. Refer to the *borg list* documentation for
|
by one object in the *items* array of the :ref:`borg_list` output. Refer to the *borg list* documentation for
|
||||||
the available keys and their meaning.
|
the available keys and their meaning.
|
||||||
|
|
||||||
Example (excerpt)::
|
Example (excerpt)::
|
||||||
|
@ -336,7 +333,7 @@ Example (excerpt)::
|
||||||
"last_modified": "Mon, 2017-02-27 21:21:58",
|
"last_modified": "Mon, 2017-02-27 21:21:58",
|
||||||
"location": "/home/user/repository"
|
"location": "/home/user/repository"
|
||||||
},
|
},
|
||||||
"files": [
|
"items": [
|
||||||
{
|
{
|
||||||
"type": "d",
|
"type": "d",
|
||||||
"mode": "drwxr-xr-x",
|
"mode": "drwxr-xr-x",
|
||||||
|
|
|
@ -1617,11 +1617,13 @@ class ArchiveFormatter(BaseFormatter):
|
||||||
|
|
||||||
def get_item_data(self, archive):
|
def get_item_data(self, archive):
|
||||||
return {
|
return {
|
||||||
|
# *name* is the key used by borg-info for the archive name, this makes the formats more compatible
|
||||||
'name': remove_surrogates(archive.name),
|
'name': remove_surrogates(archive.name),
|
||||||
'barchive': archive.name,
|
'barchive': archive.name,
|
||||||
'archive': remove_surrogates(archive.name),
|
'archive': remove_surrogates(archive.name),
|
||||||
'id': bin_to_hex(archive.id),
|
'id': bin_to_hex(archive.id),
|
||||||
'time': format_time(to_localtime(archive.ts)),
|
'time': format_time(to_localtime(archive.ts)),
|
||||||
|
# *start* is the key used by borg-info for this timestamp, this makes the formats more compatible
|
||||||
'start': format_time(to_localtime(archive.ts)),
|
'start': format_time(to_localtime(archive.ts)),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1726,7 +1728,7 @@ class ItemFormatter(BaseFormatter):
|
||||||
begin = json_dump(basic_json_data(self.archive.manifest))
|
begin = json_dump(basic_json_data(self.archive.manifest))
|
||||||
begin, _, _ = begin.rpartition('\n}') # remove last closing brace, we want to extend the object
|
begin, _, _ = begin.rpartition('\n}') # remove last closing brace, we want to extend the object
|
||||||
begin += ',\n'
|
begin += ',\n'
|
||||||
begin += ' "files": [\n'
|
begin += ' "items": [\n'
|
||||||
return begin
|
return begin
|
||||||
|
|
||||||
def end(self):
|
def end(self):
|
||||||
|
|
|
@ -1535,17 +1535,17 @@ class ArchiverTestCase(ArchiverTestCaseBase):
|
||||||
|
|
||||||
list_archive = json.loads(self.cmd('list', '--json', self.repository_location + '::test'))
|
list_archive = json.loads(self.cmd('list', '--json', self.repository_location + '::test'))
|
||||||
assert list_repo['repository'] == list_archive['repository']
|
assert list_repo['repository'] == list_archive['repository']
|
||||||
files = list_archive['files']
|
items = list_archive['items']
|
||||||
assert len(files) == 2
|
assert len(items) == 2
|
||||||
file1 = files[1]
|
file1 = items[1]
|
||||||
assert file1['path'] == 'input/file1'
|
assert file1['path'] == 'input/file1'
|
||||||
assert file1['size'] == 81920
|
assert file1['size'] == 81920
|
||||||
|
|
||||||
list_archive = json.loads(self.cmd('list', '--json', '--format={sha256}', self.repository_location + '::test'))
|
list_archive = json.loads(self.cmd('list', '--json', '--format={sha256}', self.repository_location + '::test'))
|
||||||
assert list_repo['repository'] == list_archive['repository']
|
assert list_repo['repository'] == list_archive['repository']
|
||||||
files = list_archive['files']
|
items = list_archive['items']
|
||||||
assert len(files) == 2
|
assert len(items) == 2
|
||||||
file1 = files[1]
|
file1 = items[1]
|
||||||
assert file1['path'] == 'input/file1'
|
assert file1['path'] == 'input/file1'
|
||||||
assert file1['sha256'] == 'b2915eb69f260d8d3c25249195f2c8f4f716ea82ec760ae929732c0262442b2b'
|
assert file1['sha256'] == 'b2915eb69f260d8d3c25249195f2c8f4f716ea82ec760ae929732c0262442b2b'
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue