Penguin
Diff: SambaShadowCopyHowto
EditPageHistoryDiffInfoLikePages

Differences between version 6 and predecessor to the previous major change of SambaShadowCopyHowto.

Other diffs: Previous Revision, Previous Author, or view the Annotated Edit History

Newer page: version 6 Last edited on Friday, April 28, 2006 11:57:12 am by CraigBox Revert
Older page: version 1 Last edited on Thursday, April 27, 2006 12:10:26 pm by CraigBox Revert
@@ -17,10 +17,84 @@
 This document is written using Ubuntu Dapper, but you should be able to use the information on any distribution with new enough components. 
  
 * [Samba] 3.0.3 or higher 
 * A kernel that supports [LVM] and [XFS] 
+* An [LVM] volume. Create one, if you haven't already.  
+  
+[LVM] provides a method for taking a snapshot of a volume; it is these snapshots that will be shared and provided to Windows clients as shadow copies. [XFS] supports freezing a file system, buffering writes to it until it is thawed again. However, this [doesn't actually work|http://oss.sgi.com/bugzilla/show_bug.cgi?id=400] right now. Many filesystems in the kernel support [waiting until the filesystem is consistent before taking a snapshot|http://www.tldp.org/HOWTO/LVM-HOWTO/snapshotintro.html] - you might wish to research this in more detail, but for this HOWTO we will use XFS.  
+  
+!Steps  
+  
+1. Join a Windows domain, if you need to. I followed [this howto|http://www.ubuntuforums.org/showthread.php?t=91510], which should be rolled into our wiki, which is a huge mess of conflicting information about joining Windows domains that really needs some Aristotle love.  
+  
+It's always handy to keep in time with your Windows network, so install ntp-simple and edit /etc/ntp.conf to parent off your AD server.  
+  
+2. Set up a Samba share to the root of your LVM volume. Unfortunately, shadow copies don't work if you share a directory inside the volume. You can use "deep mounting" on Windows 2000 clients (net use Z: \\server\share\directory\directory) if you wish to get around this.  
+  
+3. If "lsmod | grep dm" doesn't report dm_snapshot, add "dm_snapshot" to /etc/modules.  
+  
+4. If you're on Debian or Ubuntu, check /etc/udev/udev.rules or /etc/udev/rules.d/20-names.rules for a line such as:  
+  
+<verbatim>  
+KERNEL=="dm-[0-9]*", NAME="dm/%n"  
+</verbatim>  
+  
+udev doesn't like the creation of devices without it having a say, so change it to  
+  
+<verbatim>  
+KERNEL=="dm-[0-9]*", OPTIONS+="ignore_device"  
+</verbatim>  
+  
+Source: [udev: LVM snapshots don't work|http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=343671#msg20]  
+  
+It would also appear that with XFS, you should ignore any websites that tell you to use xfs_freeze, as [this will hang lvcreate|http://oss.sgi.com/bugzilla/show_bug.cgi?id=400].  
+  
+5. Configure Samba.  
+  
+I have used something a little like this:  
+  
+<pre>  
+[data]  
+ comment = Snapshotted storage  
+ path = /array/storage  
+ read only = no  
+ browseable = yes  
+ force create mode = 0664  
+ force directory mode = 0775  
+ force group = "MYDOMAIN+Domain Users"  
+ writeable = yes  
+ vfs objects = shadow_copy  
+</pre>  
+  
+The important part is, of course, the shadow_copy VFS module.  
+  
+You end up with an /array/storage directory that looks like this:  
+<pre>  
+drwxr-xr-x 8 root MYDOMAIN+domain users 4096 2006-05-02 12:14 .  
+drwxr-xr-x 3 root root 4096 2006-04-27 11:28 ..  
+drwxr-xr-x 8 root MYDOMAIN+domain users 4096 2006-05-02 07:00 @GMT-2006.05.02-07.00.00  
+drwxr-xr-x 9 root MYDOMAIN+domain users 4096 2006-05-02 12:00 @GMT-2006.05.02-12.00.00  
+drwxr-xr-x 9 root MYDOMAIN+domain users 4096 2006-05-03 07:00 @GMT-2006.05.03-07.00.00  
+drwxr-xr-x 7 root MYDOMAIN+domain users 148 2006-05-03 12:00 @GMT-2006.05.03-12.00.00  
+drwxrwxr-x 2 root MYDOMAIN+domain users 31 2006-04-27 14:56 public  
+</pre>  
+  
+Samba presents you all of this, @GMT-date dirs and all. Seems you have to have this - you can't share /array/storage/public and have the shadow copies work (see point 2, above).  
+  
+5. Create some scripts to do the work for you.  
+  
+!Scripts  
+  
+OK, here's the fun part.  
+  
+I have created a rotation I call 'halfdaily', matching Windows 2003 by taking snapshots at 7am and 12pm; "before work" and "before lunch".  
+  
+; /etc/snapshots/halfdailytab : The table of snapshot date/times. Scripts will mount and umount these at boot/shutdown, and rotate them as appropriate.  
+  
+; /usr/local/sbin/create-snapshot : Creates a snapshot.  
+  
  
-[LVM] provides a method for taking a snapshot of a volume; it is these snapshots that will be shared and provided to Windows clients as shadow copies. [XFS] supports freezing a file system, buffering writes to it until it is thawed again. To be sure of the integrity of your snapshot, you need to do this. It seems like it's possible to do this on [Ext3] file systems, but without a similar method for freezing, you could lose data.  
  
 !Links 
  
 * [How to use the Shadow Copy client|http://www.petri.co.il/how_to_use_the_shadow_copy_client.htm] 
+* [Some useful information about XFS & snapshots|http://c.mills.ctru.auckland.ac.nz/Samba/XfsAclWinAuth.html]