3 The purpose of this document is to demonstarate to the reader how to restore data on a hammer
4 filesystem(files/directories). This will also cover how to adjust history retention.
6 # Getting history records of a file
8 To get all history records of a file we will use hammer utility with 'history' command giving it
13 test 0000000110d66ec3 clean {
14 0000000110d6e970 04-Jan-2011 15:36:38
17 # echo "world" >> test
19 test 0000000110d66ec3 clean {
20 0000000110d6e970 04-Jan-2011 15:36:38
21 0000000110d6e9d0 04-Jan-2011 15:37:09
24 # echo "some more data" >> test
26 test 0000000110d66ec3 clean {
27 0000000110d6e970 04-Jan-2011 15:36:38
28 0000000110d6e9d0 04-Jan-2011 15:37:09
29 0000000110d6ea10 04-Jan-2011 15:37:40
32 You probably wonder what are these strange hexadecimal numbers are:
38 Well, they are transaction ids. Transaction id is a 64 bit hexadecimal number used by hammer file
39 system to refer to historical file or directory data.You will need them to restore file to a prior
44 To restore a file to a prior version we will use **undo** utility. For example lets restore the test
45 file to it's prior version created in previous section.
48 test 0000000110d66ec3 clean {
49 0000000110d6e970 04-Jan-2011 15:36:38
50 0000000110d6e9d0 04-Jan-2011 15:37:09
51 0000000110d6ea10 04-Jan-2011 15:37:40
54 Get data that refers to transaction id and put it in test.old
56 # undo -o test.old -t 0x0000000110d6e9d0 test
65 You can aslo specify the 'd' flag and get a diff output
67 # undo -d -o test.diff -t 0x0000000110d6e9d0 test
69 --- test@@0x000000110d6e9d0 2010-01-04 15:36:31 -0600
70 +++ test 2011-01-04 15:37:32 -0600
78 To restore directory to a prior version we are going to be using **cpdup** command and special hammer notation '@@'.
80 first we need to get history records for the directory, to get them we are going to use **undo** utility.
83 test: ITERATE ENTIRE HISTORY
84 0x00000001126152b0 04-Jan-2011 21:08:22
85 0x0000000112615330 04-Jan-2011 21:08:42
89 As you can see i already create two files in the test directory.
90 Now lets restore prior version of the test directory.
92 # cpdup test@@0x00000001126152b0 testold
96 You can use '@@' notation to access to prior versions of files or directories.
99 dirname/filename@@0x_64bit tid
101 However the common way of accessing history is by taking a snapshot.
103 # Adjusting History retention
104 Hammer will efficiantly fill your hard disk with history if you don't prune, or defrag.To cleanup and free space there is a **hammer cleanup** command it reblocks,prunes,rebalances,etc. DragonFly runs it by the default nightly via [periodic(8)](http://leaf.dragonflybsd.org/cgi/web-man?command=periodic§ion=8).
106 **hammer cleanup** will access the configuration file for each filesystem, creating them if necessary.
108 The format of the configuration file(**hammer viconfig** filesystem):
110 snapshots <period> <retention-time> [any]
111 prune <period> <max-runtime>
112 rebalance <period> <max-runtime>
113 dedup <period> <max-runtime>
114 reblock <period> <max-runtime>
115 recopy <period> <max-runtime>
126 If period hasn't passed since the previous cleanup run nothing is done.
128 By the default configuration file will create a daily snapshot, basicly what it means is it will make a snapshot every 24hr for 60 days, you can find your snapshots in /var/hammer/<pfs>/snapshots.
129 It will aslo do a daily pruning for example if you want it to run everyday for 30 minutes the configuration will look like this:
133 rebalancing, deduping(This feature is introduced in 2.9 DragonFly kernel version wich at the moment is being developed),
134 reblocking - reblocking will reorder all elements and thus defragment the file system and free space for reuse. And do a montly recopy run.