@@ -3,127 +3,81 @@ btrfs-snapshots-diff
3
3
4
4
About
5
5
-----
6
- ` btrfs-snapshots-diff.py ` is a simple Python2 script that displays the differences
6
+ ` btrfs-snapshots-diff.py ` is a simple Python3 script that displays the differences
7
7
between two Btrfs snapshots (from the same subvolume obviously).
8
8
9
- Uses btrfs send to compute the differences, decodes the stream and
9
+ Uses ` btrfs send --no-data ` to compute the differences, decodes the stream and
10
10
displays the differences.
11
11
12
- Can read data from parent and current snapshots, or from diff file created with:
13
-
14
- ` btrfs send -p parent chid --no-data -f /tmp/snaps-diff `
15
-
16
12
Usage
17
13
-----
18
- usage: btrfs-snapshots-diff.py [ -h] [ -p PARENT] [ -c CHILD] [ -f FILE] [ -t] [ -a] [ -s] [ -j] [ -b]
19
-
20
- Display differences between 2 Btrfs snapshots
21
-
22
- optional arguments:
23
- -h, --help show this help message and exit
24
- -p PARENT, --parent PARENT
25
- parent snapshot (must exists and be readonly)
26
- -c CHILD, --child CHILD
27
- child snapshot (will be created if it does not exist)
28
- -f FILE, --file FILE diff file
29
- -t, --filter does not display temporary files, nor all time modifications
30
- (just latest)
31
- -a, --by_path Group commands by path
32
- -s, --csv CSV output
33
- -j, --json JSON output (commands only)
34
- -b, --bogus Add bogus renamed_from action (used only when grouping by path)
35
-
36
-
37
- Option ` --json ` (` -j ` ), available for commands only, will output a list of
14
+ usage: btrfs-snapshots-diff.py [options] -p PARENT -c CHILD
15
+ btrfs-snapshots-diff.py [options] -f FILE
16
+
17
+ Display differences between 2 Btrfs snapshots
18
+
19
+ optional arguments:
20
+ -h, --help Show this help message and exit
21
+ -p, --parent PATH Path to PARENT (older) snapshot (must be readonly)
22
+ -c, --child PATH Path to CHILD (newer) snapshot
23
+ -f, --file FILE Path to diff file generated by
24
+ "btrfs send --no-data -p first second > FILE"
25
+ -t, --filter Do not display temporary files or any time modifications (just latest)
26
+ -a, --by_path Group commands by path
27
+ -s, --csv CSV output
28
+ -j, --json JSON output (commands only)
29
+ -b, --bogus Add bogus renamed_from action (used only when grouping by path)
30
+
31
+
32
+ * ` --json ` (` -j ` ), available for commands only, will output a list of
38
33
commands in JSON format.
39
34
40
- Option ` --csv ` (` -s ` ) will produce on line for each modification, instead of
35
+ * ` --csv ` (` -s ` ) will produce on line for each modification, instead of
41
36
formatted output: the first column is the path, then each action taken on the
42
37
file is in a new column. Separator is ";".
43
38
44
- Option ` --by_path ` (` -a ` ) groups command by path, giving a better view of what
39
+ * ` --by_path ` (` -a ` ) groups command by path, giving a better view of what
45
40
happenned on the file system.
46
41
47
- ` --bogus ` (` -b ` ) adds a bogus command to the stream, to better track renaming of
42
+ * ` --bogus ` (` -b ` ) adds a bogus command to the stream, to better track renaming of
48
43
files / dir (only usefull with ` --by_path ` ).
49
44
50
- With option ` --filter ` (` -t ` ), the script tries to be a bit smarter (only usefull
45
+ * With option ` --filter ` (` -t ` ), the script tries to be a bit smarter (only usefull
51
46
with ` --by_path ` ):
52
- * it does not display temporary files created by send stream,
53
- * it displays 'created' or 'rewritten' on the files renamed from temporary files,
54
- * it displays only the latest time modifications, if there are two or more.
47
+ * it does not display temporary files created by send stream,
48
+ * it displays 'created' or 'rewritten' on the files renamed from temporary files,
49
+ * it displays only the latest time modifications, if there are two or more.
55
50
56
51
Example
57
52
-------
58
- The example below is the result of creating a new subvolume, taking a
59
- snapshot (parent), creating some objects ( a file called "file", a
60
- directory called "dir", fifo, link and symlink...), then taking a new snapshot,
61
- and last calling btrfs-snapshots-diff to display the differences (see test.sh).
53
+ See [ ./tests.output] ( ./tests.output ) file as an example output. These outputs are created regarding to
54
+ the changes made by [ ./tests.sh] ( ./tests.sh ) :
55
+
56
+ ``` bash
57
+ touch file
58
+ mkdir dir
59
+ mkfifo fifo
60
+ ln file hardlink
61
+ ln -s file symlink
62
+ echo ' Hello Btrfs' > ' xxx;yyy;zzz'
63
+ mv file file2
64
+ ```
65
+
66
+ Tests
67
+ -----
62
68
63
- sudo ./btrfs-snapshots-diff.py -p btrfs-diff-tests.parent -c btrfs-diff-tests.child
64
- Found a valid Btrfs stream header, version 1
65
-
66
- btrfs-diff-tests.child
67
- snapshot: uuid=d6515a0a57d462449bcc9c2533d01277, ctrasid=171948, clone_uuid=b66a4f902e348b46b87d4cb85d967ad9, clone_ctransid=171945
68
-
69
- __sub_root__
70
- times a=2016/04/03 10:36:13 m=2016/04/03 10:36:15 c=2016/04/03 10:36:15
71
- times a=2016/04/03 10:36:13 m=2016/04/03 10:36:15 c=2016/04/03 10:36:15
72
- times a=2016/04/03 10:36:13 m=2016/04/03 10:36:15 c=2016/04/03 10:36:15
73
- times a=2016/04/03 10:36:13 m=2016/04/03 10:36:15 c=2016/04/03 10:36:15
74
- times a=2016/04/03 10:36:13 m=2016/04/03 10:36:15 c=2016/04/03 10:36:15
75
- times a=2016/04/03 10:36:13 m=2016/04/03 10:36:15 c=2016/04/03 10:36:15
76
-
77
- o257-171948-0
78
- mkfile
79
- rename to "file"
80
-
81
- file
82
- renamed from "o257-171948-0"
83
- xattr security.selinux 28277
84
- truncate 0
85
- owner 1000:1000
86
- mode 664
87
- times a=2016/04/03 10:36:15 m=2016/04/03 10:36:15 c=2016/04/03 10:36:15
88
-
89
- hardlink
90
- link to "file"
91
-
92
- o258-171948-0
93
- mkdir
94
- rename to "dir"
95
-
96
- dir
97
- renamed from "o258-171948-0"
98
- xattr security.selinux 28277
99
- owner 1000:1000
100
- mode 775
101
- times a=2016/04/03 10:36:15 m=2016/04/03 10:36:15 c=2016/04/03 10:36:15
102
-
103
- o259-171948-0
104
- mkfifo
105
- rename to "fifo"
106
-
107
- fifo
108
- renamed from "o259-171948-0"
109
- xattr security.selinux 28277
110
- owner 1000:1000
111
- mode 664
112
- times a=2016/04/03 10:36:15 m=2016/04/03 10:36:15 c=2016/04/03 10:36:15
113
-
114
- o260-171948-0
115
- symlink to "file"
116
- rename to "symlink"
117
-
118
- symlink
119
- renamed from "o260-171948-0"
120
- xattr security.selinux 28277
121
- owner 1000:1000
122
- times a=2016/04/03 10:36:15 m=2016/04/03 10:36:15 c=2016/04/03 10:36:15
69
+ ``` bash
70
+ ./tests.sh > tests.output
71
+ git diff # inspect visually, there should be no unexpected changes. See issue#13.
72
+ git checkout -- tests.output
73
+ ```
123
74
124
75
Requirements
125
76
------------
126
- No requirements besides Python-3!
77
+
78
+ ```
79
+ apt-get install jq
80
+ ```
127
81
128
82
Bugs
129
83
----
0 commit comments