1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-17 00:07:37 +02:00
Files
jc/docs/parsers/rsync.md

163 lines
4.6 KiB
Markdown
Raw Normal View History

2022-02-01 17:57:12 -08:00
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.rsync"></a>
# jc.parsers.rsync
2022-03-04 13:27:39 -08:00
jc - JSON Convert `rsync` command output parser
2022-02-01 17:57:12 -08:00
Supports the `-i` or `--itemize-changes` options with all levels of
2022-05-26 16:03:30 -07:00
verbosity. This parser will process the `STDOUT` output or a log file
2022-02-14 09:37:37 -08:00
generated with the `--log-file` option.
2022-02-01 17:57:12 -08:00
Usage (cli):
$ rsync -i -a source/ dest | jc --rsync
2022-08-15 13:51:48 -07:00
or
2022-02-01 17:57:12 -08:00
$ jc rsync -i -a source/ dest
2022-08-15 13:51:48 -07:00
or
2022-02-08 14:45:33 -08:00
$ cat rsync-backup.log | jc --rsync
2022-02-01 17:57:12 -08:00
Usage (module):
import jc
result = jc.parse('rsync', rsync_command_output)
Schema:
[
{
"summary": {
"date": string,
"time": string,
"process": integer,
"sent": integer,
"received": integer,
"total_size": integer,
"matches": integer,
"hash_hits": integer,
"false_alarms": integer,
"data": integer,
"bytes_sec": float,
"speedup": float
},
"files": [
{
"filename": string,
"date": string,
"time": string,
"process": integer,
"metadata": string,
2022-05-28 12:41:36 -07:00
"update_type": string/null, # [0]
"file_type": string/null, # [1]
2022-02-01 17:57:12 -08:00
"checksum_or_value_different": bool/null,
"size_different": bool/null,
"modification_time_different": bool/null,
"permissions_different": bool/null,
"owner_different": bool/null,
"group_different": bool/null,
"acl_different": bool/null,
"extended_attribute_different": bool/null,
2022-05-28 12:41:36 -07:00
"epoch": integer, # [2]
2022-02-01 17:57:12 -08:00
}
]
}
]
[0] 'file sent', 'file received', 'local change or creation',
'hard link', 'not updated', 'message'
[1] 'file', 'directory', 'symlink', 'device', 'special file'
[2] naive timestamp if time and date fields exist and can be converted.
Examples:
$ rsync -i -a source/ dest | jc --rsync -p
[
{
"summary": {
"sent": 1708,
"received": 8209,
"bytes_sec": 19834.0,
"total_size": 235,
"speedup": 0.02
},
"files": [
{
"filename": "./",
"metadata": ".d..t......",
"update_type": "not updated",
"file_type": "directory",
"checksum_or_value_different": false,
"size_different": false,
"modification_time_different": true,
"permissions_different": false,
"owner_different": false,
"group_different": false,
"acl_different": false,
"extended_attribute_different": false
},
...
]
}
]
$ rsync | jc --rsync -p -r
[
{
"summary": {
"sent": "1,708",
"received": "8,209",
"bytes_sec": "19,834.00",
"total_size": "235",
"speedup": "0.02"
},
"files": [
{
"filename": "./",
"metadata": ".d..t......",
"update_type": "not updated",
"file_type": "directory",
"checksum_or_value_different": false,
"size_different": false,
"modification_time_different": true,
"permissions_different": false,
"owner_different": false,
"group_different": false,
"acl_different": false,
"extended_attribute_different": false
},
...
]
}
]
<a id="jc.parsers.rsync.parse"></a>
2022-03-05 12:15:14 -08:00
### parse
2022-02-01 17:57:12 -08:00
```python
def parse(data: str, raw: bool = False, quiet: bool = False) -> List[Dict]
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
List of Dictionaries. Raw or processed structured data.
### Parser Information
Compatibility: linux, darwin, freebsd
2023-12-21 14:55:21 -08:00
Source: [`jc/parsers/rsync.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/rsync.py)
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)