@@ -3,127 +3,82 @@ 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 PARENT (older snapshot )
22
+ parent snapshot (must exists and be readonly)
23
+ -c, --child CHILD (newer snapshot )
24
+ child snapshot (will be created if it does not exist)
25
+ -f , --file FILE Path to diff file generated by "btrfs send --no-data -p first second > FILE"
26
+ -t, --filter do not display temporary files or any time modifications (just latest)
27
+ -a, --by_path Group commands by path
28
+ -s, --csv CSV output
29
+ -j, --json JSON output (commands only)
30
+ -b, --bogus Add bogus renamed_from action (used only when grouping by path)
31
+
32
+
33
+ * ` --json ` (` -j ` ), available for commands only, will output a list of
38
34
commands in JSON format.
39
35
40
- Option ` --csv ` (` -s ` ) will produce on line for each modification, instead of
36
+ * ` --csv ` (` -s ` ) will produce on line for each modification, instead of
41
37
formatted output: the first column is the path, then each action taken on the
42
38
file is in a new column. Separator is ";".
43
39
44
- Option ` --by_path ` (` -a ` ) groups command by path, giving a better view of what
40
+ * ` --by_path ` (` -a ` ) groups command by path, giving a better view of what
45
41
happenned on the file system.
46
42
47
- ` --bogus ` (` -b ` ) adds a bogus command to the stream, to better track renaming of
43
+ * ` --bogus ` (` -b ` ) adds a bogus command to the stream, to better track renaming of
48
44
files / dir (only usefull with ` --by_path ` ).
49
45
50
- With option ` --filter ` (` -t ` ), the script tries to be a bit smarter (only usefull
46
+ * With option ` --filter ` (` -t ` ), the script tries to be a bit smarter (only usefull
51
47
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.
48
+ * it does not display temporary files created by send stream,
49
+ * it displays 'created' or 'rewritten' on the files renamed from temporary files,
50
+ * it displays only the latest time modifications, if there are two or more.
55
51
56
52
Example
57
53
-------
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).
54
+ See [ ./tests.output] ( ./tests.output ) file as an example output. These outputs are created regarding to
55
+ the changes made by [ ./tests.sh] ( ./tests.sh ) :
56
+
57
+ ``` bash
58
+ touch file
59
+ mkdir dir
60
+ mkfifo fifo
61
+ ln file hardlink
62
+ ln -s file symlink
63
+ echo ' Hello Btrfs' > ' xxx;yyy;zzz'
64
+ mv file file2
65
+ ```
66
+
67
+ Tests
68
+ -----
62
69
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
70
+ ``` bash
71
+ ./tests.sh > tests.output
72
+ git diff # inspect visually, there should be no unexpected changes. See issue#13.
73
+ git checkout -- tests.output
74
+ ```
123
75
124
76
Requirements
125
77
------------
126
- No requirements besides Python-3!
78
+
79
+ ```
80
+ apt-get install jq
81
+ ```
127
82
128
83
Bugs
129
84
----
0 commit comments