Whamcloud - gitweb
FIX: added index.
[doc/manual.git] / BackupAndRestore.xml
1 <?xml version='1.0' encoding='UTF-8'?>
2 <!-- This document was created with Syntext Serna Free. --><chapter xmlns="http://docbook.org/ns/docbook" xmlns:xl="http://www.w3.org/1999/xlink" version="5.0" xml:lang="en-US" xml:id="backupandrestore">
3   <title xml:id="backupandrestore.title">Backing Up and Restoring a File System</title>
4   <para>Lustre provides backups at the file system-level, device-level and file-level. This chapter describes how to backup and restore on Lustre, and includes the following sections:</para>
5   <itemizedlist>
6     <listitem>
7       <para><xref linkend="dbdoclet.50438207_56395"/></para>
8     </listitem>
9     <listitem>
10       <para><xref linkend="dbdoclet.50438207_71633"/></para>
11     </listitem>
12     <listitem>
13       <para><xref linkend="dbdoclet.50438207_21638"/></para>
14     </listitem>
15     <listitem>
16       <para><xref linkend="dbdoclet.50438207_22325"/></para>
17     </listitem>
18     <listitem>
19       <para><xref linkend="dbdoclet.50438207_31553"/></para>
20     </listitem>
21   </itemizedlist>
22   <section xml:id="dbdoclet.50438207_56395">
23
24
25       <title>
26           <indexterm><primary>backup</primary></indexterm>
27           <indexterm><primary>restoring</primary><see>backup</see></indexterm>
28           <indexterm><primary>LVM</primary><see>backup</see></indexterm>
29           <indexterm><primary>rsync</primary><see>backup</see></indexterm>
30           
31           Backing up a File System</title>
32     <para>Backing up a complete file system gives you full control over the files to back up, and allows restoration of individual files as needed. File system-level backups are also the easiest to integrate into existing backup solutions.</para>
33     <para>File system backups are performed from a Lustre client (or many clients working parallel in different directories) rather than on individual server nodes; this is no different than backing up any other file system.</para>
34     <para>However, due to the large size of most Lustre file systems, it is not always possible to get a complete backup. We recommend that you back up subsets of a file system. This includes subdirectories of the entire file system, filesets for a single user, files incremented by date, and so on.</para>
35     <note>
36       <para>In order to allow Lustre to scale the filesystem namespace for future applications, Lustre 2.x internally uses a 128-bit file identifier for all files. To interface with user applications, Lustre presents 64-bit inode numbers for the <literal>stat()</literal>, <literal>fstat()</literal>, and <literal>readdir()</literal> system calls on 64-bit applications, and 32-bit inode numbers to 32-bit applications.</para>
37       <para>Some 32-bit applications accessing Lustre filesystems (on both 32-bit and 64-bit CPUs) may experience problems with the <literal>stat()</literal>, <literal>fstat()</literal> or<literal> readdir()</literal> system calls under certain circumstances, though the Lustre client should return 32-bit inode numbers to these applications.</para>
38       <para>In particular, if the Lustre filesystem is exported from a 64-bit client via NFS to a 32-bit client, the Linux NFS server will export 64-bit inode numbers to applications running on the NFS client. If the 32-bit applications are not compiled with Large File Support (LFS), then they return <literal>EOVERFLOW</literal> errors when accessing the Lustre files. To avoid this problem, Linux NFS clients can use the kernel command-line option &quot;<literal>nfs.enable_ino64=0</literal>&quot; in order to force the NFS client to export 32-bit inode numbers to the client.</para>
39       <para><emphasis role="bold">Workaround</emphasis>: We very strongly recommend that backups using <literal>tar(1)</literal> and other utilities that depend on the inode number to uniquely identify an inode to be run on 64-bit clients. The 128-bit Lustre file identifiers cannot be uniquely mapped to a 32-bit inode number, and as a result these utilities may operate incorrectly on 32-bit clients.</para>
40     </note>
41     <section remap="h3">
42       <title><indexterm><primary>backup</primary><secondary>rsync</secondary></indexterm>Lustre_rsync</title>
43       <para>The <literal>lustre_rsync </literal>feature keeps the entire file system in sync on a backup by replicating the file system&apos;s changes to a second file system (the second file system need not be a Lustre file system, but it must be sufficiently large). <literal>lustre_rsync </literal>uses Lustre changelogs to efficiently synchronize the file systems without having to scan (directory walk) the Lustre file system. This efficiency is critically important for large file systems, and distinguishes the Lustre <literal>lustre_rsync</literal> feature from other replication/backup solutions.</para>
44       <section remap="h4">
45           <title><indexterm><primary>backup</primary><secondary>rsync</secondary><tertiary>using</tertiary></indexterm>Using Lustre_rsync</title>
46         <para>The <literal>lustre_rsync</literal> feature works by periodically running <literal>lustre_rsync</literal>, a userspace program used to synchronize changes in the Lustre file system onto the target file system. The <literal>lustre_rsync</literal> utility keeps a status file, which enables it to be safely interrupted and restarted without losing synchronization between the file systems.</para>
47         <para>The first time that <literal>lustre_rsync</literal> is run, the user must specify a set of parameters for the program to use. These parameters are described in the following table and in <xref linkend="dbdoclet.50438219_63667"/>. On subsequent runs, these parameters are stored in the the status file, and only the name of the status file needs to be passed to <literal>lustre_rsync</literal>.</para>
48         <para>Before using <literal>lustre_rsync</literal>:</para>
49         <itemizedlist>
50           <listitem>
51             <para>Register the changelog user. For details, see the <xref linkend="systemconfigurationutilities"/> (<literal>changelog_register</literal>) parameter in the <xref linkend="systemconfigurationutilities"/> (<literal>lctl</literal>).</para>
52           </listitem>
53         </itemizedlist>
54         <para>- AND -</para>
55         <itemizedlist>
56           <listitem>
57             <para>Verify that the Lustre file system (source) and the replica file system (target) are identical <emphasis>before</emphasis> registering the changelog user. If the file systems are discrepant, use a utility, e.g. regular <literal>rsync</literal> (not <literal>lustre_rsync</literal>), to make them identical.</para>
58           </listitem>
59         </itemizedlist>
60         <para>The <literal>lustre_rsync</literal> utility uses the following parameters:</para>
61         <informaltable frame="all">
62           <tgroup cols="2">
63             <colspec colname="c1" colwidth="3*"/>
64             <colspec colname="c2" colwidth="10*"/>
65             <thead>
66               <row>
67                 <entry>
68                   <para><emphasis role="bold">Parameter</emphasis></para>
69                 </entry>
70                 <entry>
71                   <para><emphasis role="bold">Description</emphasis></para>
72                 </entry>
73               </row>
74             </thead>
75             <tbody>
76               <row>
77                 <entry>
78                   <para> <literal>--source=&lt;src&gt;</literal></para>
79                 </entry>
80                 <entry>
81                   <para>The path to the root of the Lustre file system (source) which will be synchronized. This is a mandatory option if a valid status log created during a previous synchronization operation (<literal>--statuslog</literal>) is not specified.</para>
82                 </entry>
83               </row>
84               <row>
85                 <entry>
86                   <para> <literal>--target=&lt;tgt&gt;</literal></para>
87                 </entry>
88                 <entry>
89                   <para>The path to the root where the source file system will be synchronized (target). This is a mandatory option if the status log created during a previous synchronization operation (<literal>--statuslog</literal>) is not specified. This option can be repeated if multiple synchronization targets are desired.</para>
90                 </entry>
91               </row>
92               <row>
93                 <entry>
94                   <para> <literal>--mdt=&lt;mdt&gt;</literal></para>
95                 </entry>
96                 <entry>
97                   <para>The metadata device to be synchronized. A changelog user must be registered for this device. This is a mandatory option if a valid status log created during a previous synchronization operation (<literal>--statuslog</literal>) is not specified.</para>
98                 </entry>
99               </row>
100               <row>
101                 <entry>
102                   <para> <literal>--user=&lt;user id&gt;</literal></para>
103                 </entry>
104                 <entry>
105                   <para>The changelog user ID for the specified MDT. To use <literal>lustre_rsync</literal>, the changelog user must be registered. For details, see the <literal>changelog_register</literal> parameter in <xref linkend="systemconfigurationutilities"/> (<literal>lctl</literal>). This is a mandatory option if a valid status log created during a previous synchronization operation (<literal>--statusl</literal>)  is not specified.</para>
106                 </entry>
107               </row>
108               <row>
109                 <entry>
110                   <para> <literal>--statuslog=&lt;log&gt;</literal></para>
111                 </entry>
112                 <entry>
113                   <para>A log file to which synchronization status is saved. When the <literal>lustre_rsync</literal> utility starts, if the status log from a previous synchronization operation is specified, then the state is read from the log and otherwise mandatory <literal>--source</literal>, <literal>--target</literal> and <literal>--mdt</literal> options can be skipped. Specifying the <literal>--source</literal>, <literal>--target</literal> and/or <literal>--mdt</literal> options, in addition to the <literal>--statuslog</literal> option, causes the specified parameters in the status log to be overriden. Command line options take precedence over options in the status log.</para>
114                 </entry>
115               </row>
116               <row>
117                 <entry>
118                   <literal> --xattr &lt;yes|no&gt; </literal>
119                 </entry>
120                 <entry>
121                   <para>Specifies whether extended attributes (<literal>xattrs</literal>) are synchronized or not. The default is to synchronize extended attributes.</para>
122                   <para><note>
123                       <para>Disabling xattrs causes Lustre striping information not to be synchronized.</para>
124                     </note></para>
125                 </entry>
126               </row>
127               <row>
128                 <entry>
129                   <para> <literal>--verbose</literal></para>
130                 </entry>
131                 <entry>
132                   <para>Produces verbose output.</para>
133                 </entry>
134               </row>
135               <row>
136                 <entry>
137                   <para> <literal>--dry-run</literal></para>
138                 </entry>
139                 <entry>
140                   <para>Shows the output of <literal>lustre_rsync</literal> commands (<literal>copy</literal>, <literal>mkdir</literal>, etc.) on the target file system without actually executing them.</para>
141                 </entry>
142               </row>
143               <row>
144                 <entry>
145                   <para> <literal>--abort-on-err</literal></para>
146                 </entry>
147                 <entry>
148                   <para>Stops processing the <literal>lustre_rsync</literal> operation if an error occurs. The default is to continue the operation.</para>
149                 </entry>
150               </row>
151             </tbody>
152           </tgroup>
153         </informaltable>
154       </section>
155       <section remap="h4">
156           <title><indexterm><primary>backup</primary><secondary>rsync</secondary><tertiary>examples</tertiary></indexterm><literal>lustre_rsync</literal> Examples</title>
157         <para>Sample <literal>lustre_rsync</literal> commands are listed below.</para>
158         <para>Register a changelog user for an MDT (e.g. <literal>lustre-MDT0000</literal>).</para>
159         <screen># lctl --device lustre-MDT0000 changelog_register lustre-MDT0000 Registered\
160  changelog userid &apos;cl1&apos;</screen>
161         <para>Synchronize a Lustre file system (<literal>/mnt/lustre</literal>) to a target file system (<literal>/mnt/target</literal>).</para>
162         <screen>$ lustre_rsync --source=/mnt/lustre --target=/mnt/target --mdt=lustre-MDT00\
163 00 --user=cl1 --statuslog sync.log  --verbose 
164 Lustre filesystem: lustre 
165 MDT device: lustre-MDT0000 
166 Source: /mnt/lustre 
167 Target: /mnt/target 
168 Statuslog: sync.log 
169 Changelog registration: cl1 
170 Starting changelog record: 0 
171 Errors: 0 
172 lustre_rsync took 1 seconds 
173 Changelog records consumed: 22</screen>
174         <para>After the file system undergoes changes, synchronize the changes onto the target file system. Only the <literal>statuslog</literal> name needs to be specified, as it has all the parameters passed earlier.</para>
175         <screen>$ lustre_rsync --statuslog sync.log --verbose 
176 Replicating Lustre filesystem: lustre 
177 MDT device: lustre-MDT0000 
178 Source: /mnt/lustre 
179 Target: /mnt/target 
180 Statuslog: sync.log 
181 Changelog registration: cl1 
182 Starting changelog record: 22 
183 Errors: 0 
184 lustre_rsync took 2 seconds 
185 Changelog records consumed: 42</screen>
186         <para>To synchronize a Lustre file system (<literal>/mnt/lustre</literal>) to two target file systems (<literal>/mnt/target1</literal> and <literal>/mnt/target2</literal>).</para>
187         <screen>$ lustre_rsync --source=/mnt/lustre --target=/mnt/target1 --target=/mnt/tar\
188 get2 \ 
189            --mdt=lustre-MDT0000 --user=cl1 
190            --statuslog sync.log</screen>
191       </section>
192     </section>
193   </section>
194   <section xml:id="dbdoclet.50438207_71633">
195       <title><indexterm><primary>backup</primary><secondary>MDS/OST device level</secondary></indexterm>Backing Up and Restoring an MDS or OST (Device Level)</title>
196     <para>In some cases, it is useful to do a full device-level backup of an individual device (MDT or OST), before replacing hardware, performing maintenance, etc. Doing full device-level backups ensures that all of the data and configuration files is preserved in the original state and is the easiest method of doing a backup. For the MDT file system, it may also be the fastest way to perform the backup and restore, since it can do large streaming read and write operations at the maximum bandwidth of the underlying devices.</para>
197     <note>
198       <para>Keeping an updated full backup of the MDT is especially important because a permanent failure of the MDT file system renders the much larger amount of data in all the OSTs largely inaccessible and unusable.</para>
199     </note>
200     <note>
201       <para>In Lustre 2.0 and 2.1 the only correct way to perform an MDT backup and restore is to do a device-level backup as is described in this section. The ability to do MDT file-level backups is not functional in these releases because of the inability to restore the Object Index (OI) file correctly (see bug 22741 for details).</para>
202     </note>
203     <para>If hardware replacement is the reason for the backup or if a spare storage device is available, it is possible to do a raw copy of the MDT or OST from one block device to the other, as long as the new device is at least as large as the original device. To do this, run:</para>
204     <screen>dd if=/dev/{original} of=/dev/{new} bs=1M</screen>
205     <para>If hardware errors cause read problems on the original device, use the command below to allow as much data as possible to be read from the original device while skipping sections of the disk with errors:</para>
206     <screen>dd if=/dev/{original} of=/dev/{new} bs=4k conv=sync,noerror count={original\
207  size in 4kB blocks}</screen>
208     <para>Even in the face of hardware errors, the <literal>ldiskfs</literal> file system is very robust and it may be possible to recover the file system data after running <literal>e2fsck -f</literal> on the new device.</para>
209   </section>
210   <section xml:id="dbdoclet.50438207_21638">
211     <title><indexterm><primary>backup</primary><secondary>OST file system</secondary></indexterm>Making a File-Level Backup of an OST File System</title>
212     <para>This procedure provides another way to backup or migrate the data of an OST at the file level, so that the unused space of the OST does not need to be backed up. Backing up a single OST device is not necessarily the best way to perform backups of the Lustre file system, since the files stored in the backup are not usable without metadata stored on the MDT. However, it is the preferred method for migration of OST devices, especially when it is desirable to reformat the underlying file system with different configuration options or to reduce fragmentation.</para>
213     <note>
214       <para>In Lustre 2.0 and 2.1 the only correct way to perform an MDT backup and restore is to do a device-level backup as is described in this section. The ability to do MDT file-level backups is not functional in these releases because of the inability to restore the Object Index (OI) file correctly (see bug 22741 for details).</para>
215     </note>
216     <orderedlist>
217       <listitem>
218         <para><emphasis role="bold">Make a mountpoint for the file system.</emphasis></para>
219         <screen>[oss]# mkdir -p /mnt/ost</screen>
220       </listitem>
221       <listitem>
222         <para><emphasis role="bold">Mount the file system.</emphasis></para>
223         <screen>[oss]# mount -t ldiskfs /<emphasis>dev</emphasis>/{ostdev} /mnt/ost</screen>
224       </listitem>
225       <listitem>
226         <para><emphasis role="bold">Change to the mountpoint being backed up.</emphasis></para>
227         <screen>[oss]# cd /mnt/ost</screen>
228       </listitem>
229       <listitem>
230         <para><emphasis role="bold">Back up the extended attributes.</emphasis></para>
231         <screen>[oss]# getfattr -R -d -m &apos;.*&apos; -e hex -P . &gt; ea-$(date +%Y%m%d).bak</screen>
232         <note>
233           <para>If the <literal>tar(1)</literal> command supports the <literal>--xattr</literal> option, the <literal>getfattr</literal> step may be unnecessary as long as it does a backup of the &quot;trusted&quot; attributes. However, completing this step is not harmful and can serve as an added safety measure.</para>
234         </note>
235         <note>
236           <para>In most distributions, the <literal>getfattr</literal> command is part of the &quot;<literal>attr</literal>&quot; package. If the <literal>getfattr</literal> command returns errors like <literal>Operation not supported</literal>, then the kernel does not correctly support EAs. Stop and use a different backup method.</para>
237         </note>
238       </listitem>
239       <listitem>
240         <para><emphasis role="bold">Verify that the <literal>ea-$date.bak</literal> file has properly backed up the EA data on the OST.</emphasis></para>
241         <para>Without this attribute data, the restore process may be missing extra data that can be very useful in case of later file system corruption. Look at this file with more or a text editor. Each object file should have a corresponding item similar to this:</para>
242         <screen>[oss]# file: O/0/d0/100992
243 trusted.fid= \
244 0x0d822200000000004a8a73e500000000808a0100000000000000000000000000</screen>
245       </listitem>
246       <listitem>
247         <para><emphasis role="bold">Back up all file system data.</emphasis></para>
248         <screen>[oss]# tar czvf {backup file}.tgz --sparse .</screen>
249         <note>
250           <para>In Lustre 1.6.7 and later, the <literal>--sparse</literal> option reduces the size of the backup file. Be sure to use it so the tar command does not mistakenly create an archive full of zeros.</para>
251         </note>
252       </listitem>
253       <listitem>
254         <para><emphasis role="bold">Change directory out of the file system.</emphasis></para>
255         <screen>[oss]# cd -</screen>
256       </listitem>
257       <listitem>
258         <para><emphasis role="bold">Unmount the file system.</emphasis></para>
259         <screen>[oss]# umount /mnt/ost</screen>
260         <note>
261           <para>When restoring an OST backup on a different node as part of an OST migration, you also have to change server NIDs and use the <literal>--writeconf</literal> command to re-generate the configuration logs. See <xref linkend="lustremaintenance"/> (Changing a Server NID).</para>
262         </note>
263       </listitem>
264     </orderedlist>
265   </section>
266   <section xml:id="dbdoclet.50438207_22325">
267     <title><indexterm><primary>backup</primary><secondary>restoring file system backup</secondary></indexterm>Restoring a File-Level Backup</title>
268     <para>To restore data from a file-level backup, you need to format the device, restore the file data and then restore the EA data.</para>
269     <orderedlist>
270       <listitem>
271         <para>Format the new device.</para>
272         <screen>[oss]# mkfs.lustre --ost --index {<emphasis>OST index</emphasis>} {<emphasis>other options</emphasis>} newdev}</screen>
273       </listitem>
274       <listitem>
275         <para>Mount the file system.</para>
276         <screen>[oss]# mount -t ldiskfs {<emphasis>newdev</emphasis>} /mnt/ost</screen>
277       </listitem>
278       <listitem>
279         <para>Change to the new file system mount point.</para>
280         <screen>[oss]# cd /mnt/ost</screen>
281       </listitem>
282       <listitem>
283         <para>Restore the file system backup.</para>
284         <screen>[oss]# tar xzvpf {<emphasis>backup file</emphasis>} --sparse</screen>
285       </listitem>
286       <listitem>
287         <para>Restore the file system extended attributes.</para>
288         <screen>[oss]# setfattr --restore=ea-${date}.bak</screen>
289       </listitem>
290       <listitem>
291         <para>Verify that the extended attributes were restored.</para>
292         <screen>[oss]# getfattr -d -m &quot;.*&quot; -e hex O/0/d0/100992 trusted.fid= \
293 0x0d822200000000004a8a73e500000000808a0100000000000000000000000000</screen>
294       </listitem>
295       <listitem>
296         <para>Change directory out of the file system.</para>
297         <screen>[oss]# cd -</screen>
298       </listitem>
299       <listitem>
300         <para>Unmount the new file system.</para>
301         <screen>[oss]# umount /mnt/ost</screen>
302       </listitem>
303     </orderedlist>
304     <para>If the file system was used between the time the backup was made and when it was restored, then the <literal>lfsck</literal> tool (part of Lustre <literal>e2fsprogs</literal>) can optionally be run to ensure the file system is coherent. If all of the device file systems were backed up at the same time after the entire Lustre file system was stopped, this is not necessary. In either case, the file system should be immediately usable even if <literal>lfsck</literal> is not run, though there may be I/O errors reading from files that are present on the MDT but not the OSTs, and files that were created after the MDT backup will not be accessible/visible.</para>
305   </section>
306   <section xml:id="dbdoclet.50438207_31553">
307     <title><indexterm><primary>backup</primary><secondary>using LVM</secondary></indexterm>Using LVM Snapshots with Lustre</title>
308     <para>If you want to perform disk-based backups (because, for example, access to the backup system needs to be as fast as to the primary Lustre file system), you can use the Linux LVM snapshot tool to maintain multiple, incremental file system backups.</para>
309     <para>Because LVM snapshots cost CPU cycles as new files are written, taking snapshots of the main Lustre file system will probably result in unacceptable performance losses. You should create a new, backup Lustre file system and periodically (e.g., nightly) back up new/changed files to it. Periodic snapshots can be taken of this backup file system to create a series of &quot;full&quot; backups.</para>
310     <note>
311       <para>Creating an LVM snapshot is not as reliable as making a separate backup, because the LVM snapshot shares the same disks as the primary MDT device, and depends on the primary MDT device for much of its data. If the primary MDT device becomes corrupted, this may result in the snapshot being corrupted.</para>
312     </note>
313     <section remap="h3">
314         <title><indexterm><primary>backup</primary><secondary>using LVM</secondary><tertiary>creating</tertiary></indexterm>Creating an LVM-based Backup File System</title>
315       <para>Use this procedure to create a backup Lustre file system for use with the LVM snapshot mechanism.</para>
316       <orderedlist>
317         <listitem>
318           <para>Create LVM volumes for the MDT and OSTs.</para>
319           <para>Create LVM devices for your MDT and OST targets. Make sure not to use the entire disk for the targets; save some room for the snapshots. The snapshots start out as 0 size, but grow as you make changes to the current file system. If you expect to change 20% of the file system between backups, the most recent snapshot will be 20% of the target size, the next older one will be 40%, etc. Here is an example:</para>
320           <screen>cfs21:~# pvcreate /dev/sda1
321    Physical volume &quot;/dev/sda1&quot; successfully created
322 cfs21:~# vgcreate volgroup /dev/sda1
323    Volume group &quot;volgroup&quot; successfully created
324 cfs21:~# lvcreate -L200M -nMDT volgroup
325    Logical volume &quot;MDT&quot; created
326 cfs21:~# lvcreate -L200M -nOST0 volgroup
327    Logical volume &quot;OST0&quot; created
328 cfs21:~# lvscan
329    ACTIVE                  &apos;/dev/volgroup/MDT&apos; [200.00 MB] inherit
330    ACTIVE                  &apos;/dev/volgroup/OST0&apos; [200.00 MB] inherit</screen>
331         </listitem>
332         <listitem>
333           <para>Format the LVM volumes as Lustre targets.</para>
334           <para>In this example, the backup file system is called &apos;main&apos; and designates the current, most up-to-date backup.</para>
335           <screen>cfs21:~# mkfs.lustre --mdt --fsname=main /dev/volgroup/MDT
336  No management node specified, adding MGS to this MDT.
337     Permanent disk data:
338  Target:     main-MDTffff
339  Index:      unassigned
340  Lustre FS:  main
341  Mount type: ldiskfs
342  Flags:      0x75
343                (MDT MGS needs_index first_time update )
344  Persistent mount opts: errors=remount-ro,iopen_nopriv,user_xattr
345  Parameters:
346 checking for existing Lustre data
347  device size = 200MB
348  formatting backing filesystem ldiskfs on /dev/volgroup/MDT
349          target name  main-MDTffff
350          4k blocks     0
351          options        -i 4096 -I 512 -q -O dir_index -F
352  mkfs_cmd = mkfs.ext2 -j -b 4096 -L main-MDTffff  -i 4096 -I 512 -q -O dir_\
353 index -F /dev/volgroup/MDT
354  Writing CONFIGS/mountdata
355 cfs21:~# mkfs.lustre --ost --mgsnode=cfs21 --fsname=main /dev/volgroup/OST0
356     Permanent disk data:
357  Target:     main-OSTffff
358 Index:      unassigned
359  Lustre FS:  main
360  Mount type: ldiskfs
361  Flags:      0x72
362                (OST needs_index first_time update )
363  Persistent mount opts: errors=remount-ro,extents,mballoc
364  Parameters: mgsnode=192.168.0.21@tcp
365 checking for existing Lustre data
366  device size = 200MB
367  formatting backing filesystem ldiskfs on /dev/volgroup/OST0
368          target name  main-OSTffff
369          4k blocks     0
370          options        -I 256 -q -O dir_index -F
371  mkfs_cmd = mkfs.ext2 -j -b 4096 -L main-OSTffff  -I 256 -q -O dir_index -F\
372  /dev/ volgroup/OST0
373  Writing CONFIGS/mountdata
374 cfs21:~# mount -t lustre /dev/volgroup/MDT /mnt/mdt
375 cfs21:~# mount -t lustre /dev/volgroup/OST0 /mnt/ost
376 cfs21:~# mount -t lustre cfs21:/main /mnt/main</screen>
377         </listitem>
378       </orderedlist>
379     </section>
380     <section remap="h3">
381         <title><indexterm><primary>backup</primary><secondary>new/changed files</secondary></indexterm>Backing up New/Changed Files to the Backup File System</title>
382       <para>At periodic intervals e.g., nightly, back up new and changed files to the LVM-based backup file system.</para>
383       <screen>cfs21:~# cp /etc/passwd /mnt/main 
384  
385 cfs21:~# cp /etc/fstab /mnt/main 
386  
387 cfs21:~# ls /mnt/main 
388 fstab  passwd</screen>
389     </section>
390     <section remap="h3">
391         <title><indexterm><primary>backup</primary><secondary>using LVM</secondary><tertiary>createing snapshots</tertiary></indexterm>Creating Snapshot Volumes</title>
392       <para>Whenever you want to make a &quot;checkpoint&quot; of the main Lustre file system, create LVM snapshots of all target MDT and OSTs in the LVM-based backup file system. You must decide the maximum size of a snapshot ahead of time, although you can dynamically change this later. The size of a daily snapshot is dependent on the amount of data changed daily in the main Lustre file system. It is likely that a two-day old snapshot will be twice as big as a one-day old snapshot.</para>
393       <para>You can create as many snapshots as you have room for in the volume group. If necessary, you can dynamically add disks to the volume group.</para>
394       <para>The snapshots of the target MDT and OSTs should be taken at the same point in time. Make sure that the cronjob updating the backup file system is not running, since that is the only thing writing to the disks. Here is an example:</para>
395       <screen>cfs21:~# modprobe dm-snapshot
396 cfs21:~# lvcreate -L50M -s -n MDTb1 /dev/volgroup/MDT
397    Rounding up size to full physical extent 52.00 MB
398    Logical volume &quot;MDTb1&quot; created
399 cfs21:~# lvcreate -L50M -s -n OSTb1 /dev/volgroup/OST0
400    Rounding up size to full physical extent 52.00 MB
401    Logical volume &quot;OSTb1&quot; created</screen>
402       <para>After the snapshots are taken, you can continue to back up new/changed files to &quot;main&quot;. The snapshots will not contain the new files.</para>
403       <screen>cfs21:~# cp /etc/termcap /mnt/main
404 cfs21:~# ls /mnt/main
405 fstab  passwd  termcap</screen>
406     </section>
407     <section remap="h3">
408         <title><indexterm><primary>backup</primary><secondary>using LVM</secondary><tertiary>restoring</tertiary></indexterm>Restoring the File System From a Snapshot</title>
409       <para>Use this procedure to restore the file system from an LVM snapshot.</para>
410       <orderedlist>
411         <listitem>
412           <para>Rename the LVM snapshot.</para>
413           <para>Rename the file system snapshot from &quot;main&quot; to &quot;back&quot; so you can mount it without unmounting &quot;main&quot;. This is recommended, but not required. Use the <literal>--reformat</literal> flag to <literal>tunefs.lustre</literal> to force the name change. For example:</para>
414           <screen>cfs21:~# tunefs.lustre --reformat --fsname=back --writeconf /dev/volgroup/M\
415 DTb1
416  checking for existing Lustre data
417  found Lustre data
418  Reading CONFIGS/mountdata
419 Read previous values:
420  Target:     main-MDT0000
421  Index:      0
422  Lustre FS:  main
423  Mount type: ldiskfs
424  Flags:      0x5
425               (MDT MGS )
426  Persistent mount opts: errors=remount-ro,iopen_nopriv,user_xattr
427  Parameters:
428 Permanent disk data:
429  Target:     back-MDT0000
430  Index:      0
431  Lustre FS:  back
432  Mount type: ldiskfs
433  Flags:      0x105
434               (MDT MGS writeconf )
435  Persistent mount opts: errors=remount-ro,iopen_nopriv,user_xattr
436  Parameters:
437 Writing CONFIGS/mountdata
438 cfs21:~# tunefs.lustre --reformat --fsname=back --writeconf /dev/volgroup/O\
439 STb1
440  checking for existing Lustre data
441  found Lustre data
442  Reading CONFIGS/mountdata
443 Read previous values:
444  Target:     main-OST0000
445  Index:      0
446  Lustre FS:  main
447  Mount type: ldiskfs
448  Flags:      0x2
449               (OST )
450  Persistent mount opts: errors=remount-ro,extents,mballoc
451  Parameters: mgsnode=192.168.0.21@tcp
452 Permanent disk data:
453  Target:     back-OST0000
454  Index:      0
455  Lustre FS:  back
456  Mount type: ldiskfs
457  Flags:      0x102
458               (OST writeconf )
459  Persistent mount opts: errors=remount-ro,extents,mballoc
460  Parameters: mgsnode=192.168.0.21@tcp
461 Writing CONFIGS/mountdata
462 When renaming an FS, we must also erase the last_rcvd file from the snapsho\
463 ts
464 cfs21:~# mount -t ldiskfs /dev/volgroup/MDTb1 /mnt/mdtback
465 cfs21:~# rm /mnt/mdtback/last_rcvd
466 cfs21:~# umount /mnt/mdtback
467 cfs21:~# mount -t ldiskfs /dev/volgroup/OSTb1 /mnt/ostback
468 cfs21:~# rm /mnt/ostback/last_rcvd
469 cfs21:~# umount /mnt/ostback</screen>
470         </listitem>
471         <listitem>
472           <para>Mount the file system from the LVM snapshot.</para>
473           <para>For example:</para>
474           <screen>cfs21:~# mount -t lustre /dev/volgroup/MDTb1 /mnt/mdtback                  \
475                                                             
476 cfs21:~# mount -t lustre /dev/volgroup/OSTb1 /mnt/ostback
477 cfs21:~# mount -t lustre cfs21:/back /mnt/back</screen>
478         </listitem>
479         <listitem>
480           <para>Note the old directory contents, as of the snapshot time.</para>
481           <para>For example:</para>
482           <screen>cfs21:~/cfs/b1_5/lustre/utils# ls /mnt/back
483 fstab  passwds</screen>
484         </listitem>
485       </orderedlist>
486     </section>
487     <section remap="h3">
488         <title><indexterm><primary>backup</primary><secondary>using LVM</secondary><tertiary>deleting</tertiary></indexterm>Deleting Old Snapshots</title>
489       <para>To reclaim disk space, you can erase old snapshots as your backup policy dictates. Run:</para>
490       <screen>lvremove /dev/volgroup/MDTb1</screen>
491     </section>
492     <section remap="h3">
493       <title><indexterm><primary>backup</primary><secondary>using LVM</secondary><tertiary>resizing</tertiary></indexterm>Changing Snapshot Volume Size</title>
494       <para>You can also extend or shrink snapshot volumes if you find your daily deltas are smaller or larger than expected. Run:</para>
495       <screen>lvextend -L10G /dev/volgroup/MDTb1</screen>
496       <note>
497         <para>Extending snapshots seems to be broken in older LVM. It is working in LVM v2.02.01.</para>
498       </note>
499     </section>
500   </section>
501 </chapter>