User Tools

Site Tools


timemachine

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

timemachine [2013/05/12 20:46]
— (current)
Line 1: Line 1:
-====== Time Capsule on OpenWRT (Apple File Protocol Server with Time Machine Support) ====== 
  
-===== Intro ===== 
- 
-Time Machine is Apple'​s backup software. It is included with Mac OS X and was introduced with the 10.5 "​Leopard"​ release of Mac OS X. The software is designed to work with internal or external drives, as well as with Apple'​s Time Capsule. Time Capsule is (among other things) a wireless router with a built in hard drive. ​ It will advertize itself on a network and allow Mac computers to back up wirelessly using Time Machine with a minimum of user configuration. ​ This wiki documents how to make your OpenWRT router behave like a Time Capsule. 
- 
-This following configuration is for the stable release of Attitude Adjustment 12.09 (r36088). ​ It was developed and tested with a Mac running OSX 10.8.3. ​ These directions have been verified on a Netgear WNDR3800 using a new installation of OpenWRT. ​ There are many examples on the web for configuring a Time Capsule on linux systems. ​ Many of these contain conflicting,​ incorrect, or superfluous information. ​ This wiki is an attempt to detail the minimum configuration required to run a Time Capsule on OpenWRT. ​ There are three basic steps to configuring Time Capsule: 
- 
-  - Formatting, mounting, and configuring an external USB Drive 
-  - Installing and configuring netatalk 
-  - Installing and configuring avahi 
- 
-===== Formatting, Mounting and Configuring an External USB Drive ===== 
- 
-Time Machine will work with other filesystems,​ but the Mac native HFS+ is recommended. ​ If your router should die, you can simply plug the external drive into your Mac to recover the data. 
- 
-Plug the external drive to a Mac and use the Disk Utility to create a single partition. ​ Use the GUID layout for the partitioning and select the "Mac OS Extended (Journalled)"​ format. ​ When this is complete, use the following command (on the Mac) to turn off journalling:​ 
- 
-<​code>​ 
-/​usr/​sbin/​diskutil disableJournal /​Volumes/<​name_of_volume>​ 
-</​code>​ 
- 
-A user name and password will be required to connect to the Time Capsule. ​ Rather than running as root, create a new user and group. ​ For the purposes of this example, the user name is "​tmuser"​ and the group is "​timemachine"​. ​ This can be done manually, or by installing two packages and using the following commands: 
-<​code>​ 
-opkg update 
-opkg install shadow-useradd shadow-groupadd 
-groupadd timemachine 
-useradd -M -G timemachine tmuser 
-passwd tmuser 
-</​code>​ 
- 
-Create a mount point for the drive and set the ownership of the directory to the **//​timemachine//​** group. ​ For this example, the directory /​mnt/​TimeMachine will be used.  Create the read-only file to prevent writing to flash if the disk is not mounted. 
- 
-<​code>​ 
-mkdir /​mnt/​TimeMachine 
-chown root:​timemachine /​mnt/​TimeMachine 
-touch /​mnt/​TimeMachine/​USB_DISK_NOT_PRESENT 
-chmod 444 /​mnt/​TimeMachine/​USB_DISK_NOT_PRESENT 
-</​code>​ 
- 
-Install the packages required for connecting a USB drive. ​ Check out [[doc:​howto:​usb.overview]] and [[doc:​howto:​usb.essentials]] for more details. 
- 
-<​code>​ 
-opkg install kmod-usb-storage kmod-fs-hfsplus block-mount 
-</​code>​ 
- 
-  * **mkod-usb-storage:​** Kernel module for USB storage, including all dependencies.  ​ 
-  * **kmod-fs-hfsplus:​** Kernel module for the HFS+ file system that will be used by the time capsule. 
-  * **block-mount:​** Scripts for automatically mounting the drive on boot or when plugged in. 
- 
-Plug in the external drive and find the device number using the **//​blkid//​** command: 
- 
-<​code>​ 
-root@OpenWRT:​~#​ blkid 
-/​dev/​mtdblock3:​ TYPE="​squashfs" ​ 
-/dev/sda1: LABEL="​EFI"​ UUID="​70D6-1701"​ TYPE="​vfat" ​ 
-/dev/sda2: UUID="​b8212b1d-8d11-30e7-9506-eca9ac887034"​ LABEL="​TimeMachine"​ TYPE="​hfsplus" ​ 
-root@OpenWRT:​~#​ 
-</​code>​ 
- 
-Configure the drive to be automounted on startup or when plugged in.  Add the following to **/​etc/​config/​fstab**,​ where ///​dev/​sda2//​ is the drive identified using **//​blkid//​**:​ 
- 
-<​code>​ 
-config mount 
- option target ​  /​mnt/​TimeMachine 
- option device ​  /​dev/​sda2 
- option fstype ​  ​hfsplus 
- option options ​ rw,sync 
- option enabled ​ 1 
- option enabled_fsck 0 
-</​code>​ 
- 
-Mount the drive. 
- 
-<​code>​ 
-/​etc/​init.d/​fstab start 
-</​code>​ 
- 
-If this is successful, you may want to reboot the router to confirm that the drive is mounted on startup. 
- 
-Change the ownership of the mounted disk to the **//​timemachine//​** group: 
- 
-<​code>​ 
-chown -R root:​timemachine /​mnt/​TimeMachine 
-</​code>​ 
- 
-===== Netatalk ===== 
- 
-Netatalk is the linux package that supports the Apple File Protocol on linux systems, allowing for file serving, printing, and time servers. ​ It can also be configured to support Time Machine over a network, replicating the features of Apple'​s Time Capsule. ​ Starting with version 2.2, Netatalk supports the latest AFP protocol level 3.3, required to support Time Machine on OSX 10.7 (Lion) and above. ​ Thankfully, netatalk 2.2.1-5 is included in Attitude Adjustment. ​ For the purposes of this installation,​ only a Time Machine share will be configured. ​ Start by installing the **//​netatalk//​** package: 
- 
-<​code>​ 
-opkg install netatalk 
-</​code>​ 
- 
-Configure netatalk by adding the line below to **/​etc/​netatalk/​afpd.conf**. ​ Comment out all other lines. ​ This will configure a server named "​TimeMachine"​ to use the Diffie-Hellman eXchange 2 (DHX2) for authentication. ​ Refer to the man page for [[http://​linux.die.net/​man/​5/​afpd.conf|afpd.conf]] for further details on the other options. 
- 
-<​code>​ 
-"​TimeMachine"​ -uampath /​usr/​lib/​uams -uamlist uams_dhx2.so -nodebug -nouservol -icon -nosavepassword -mimicmodel RackMac 
-</​code>​ 
- 
-The volumes netatalk will make available are defined in **/​etc/​netatalk/​AppleVolumes.default**. ​ Add the line below to **/​etc/​netatalk/​AppleVolumes.default** to create the AFP time machine share, commenting out all other lines.  ​ 
- 
-<​code>​ 
-/​mnt/​TimeMachine TimeMachine volsizelimit:​150000 allow:​@timemachine rwlist:​@timemachine cnidscheme:​dbd options:​searchdb,​usedots,​invisibledots,​tm 
-</​code>​ 
- 
-The first parameter specifies the location of the shared volume, while the second specifies the name.  The Time Machine uses a CNID database to reference files on the shared volume. ​ By default, this database will be located in the root directory of the shared volume. ​ The size of the shared volume reported to time machine is set using the **//​volsizlimit//​** parameter. ​ Set this parameter to less than the full size of the disk to reserve space for the database. ​ (If the database can't be written to or is corrupted, the entire Time Machine repository may be lost)  The **//​allow//​** and **//​rwlist//​** parameters specify which users can access and write to the time machine. ​ Either specify a user name directly, or just use **//​@timemachine//​** to allow access for users in the **//​timemachine//​** group. ​ Reference the [[http://​linux.die.net/​man/​5/​applevolumes.default|AppleVolumes.default]] man page for further information on options. 
- 
-Restart netatalk and enable on boot: 
- 
-<​code>​ 
-/​etc/​init.d/​afpd stop 
-/​etc/​init.d/​afpd start 
-/​etc/​init.d/​afpd enable 
-</​code>​ 
- 
-===== Avahi ===== 
- 
-Avahi implements a protocol known as Zeroconf or Bonjour to advertise your volume on the network. ​ Install the package: 
- 
-<​code>​ 
-opkg install avahi-daemon 
-</​code>​ 
- 
-Avahi is configured via **/​etc/​avahi/​avahi-daemon.conf**,​ see [[http://​linux.die.net/​man/​5/​avahi-daemon.conf]]. ​ Only two lines of the default file need changing: 
- 
-<​code>​ 
-host-name=TimeMachine 
-enable-dbus=no 
-</​code>​ 
- 
-The first line defines the host name, which will be displayed on client computers before logging in.  The second line is not in the default file and must be added to disable dbus support. ​ dbus is a protocol for communication which can be used to communicate between Avahi and Netatalk however, for the purposes of setting up a Time Capsule, it is not required. ​ Instead, the services that Avahi advertises are defined via the XML files in **/​etc/​avahi/​services**. ​ Create the file **/​etc/​avahi/​services/​afpd.service**,​ with the following content: 
- 
-<​code>​ 
-<?xml version="​1.0"​ standalone="​no"?>​ 
-<​!DOCTYPE service-group SYSTEM "​avahi-service.dtd">​ 
-<​service-group>​ 
-<name replace-wildcards="​yes">​Time Capsule</​name>​ 
-  <​service>​ 
-    <​type>​_afpovertcp._tcp</​type>​ 
-    <​port>​548</​port>​ 
-  </​service>​ 
-  <​service>​ 
-    <​type>​_device-info._tcp</​type>​ 
-    <​port>​0</​port>​ 
-    <​txt-record>​model=TimeCapsule</​txt-record>​ 
-  </​service>​ 
-  <​service>​ 
-    <​type>​_adisk._tcp</​type>​ 
-    <​port>​9</​port>​ 
-    <​txt-record>​sys=waMA=XX:​XX:​XX:​XX:​XX:​XX,​adVF=0x100</​txt-record>​ 
-    <​txt-record>​dk1=adVF=0x83,​adVN=TimeMachine</​txt-record>​ 
-  </​service>​ 
-</​service-group>​ 
-</​code>​ 
- 
-This file defines a service group named //"​Time Capsule"//,​ divided into three sections. ​ The first two sections enable the AFP shared volume. ​ The text //"​model=TimeCapsule"//​ defines the volume as a time capsule, so that the time capsule icon is displayed in the finder. ​ The third section attaches the disk to the service group so that it shows up under the "​Select Disk" window in the time machine preferences. ​ The //"​XX:​XX:​XX:​XX:​XX:​XX"//​ in the example above should be replaced with the MAC address of the router'​s LAN interface. ​ The section //"​adVN=TimeMachine"//​ should match the name of the volume defined in afpd.conf and AppleVolumes.default. 
- 
-FIXME (Provide better explanation of XML file details.) 
- 
-Restart Avahi and enable on boot: 
- 
-<​code>​ 
-/​etc/​init.d/​avahi-daemon stop 
-/​etc/​init.d/​avahi-daemon start 
-/​etc/​init.d/​avahi-daemon enable 
-</​code>​ 
- 
-===== Configure TimeMachine ===== 
- 
-You can now use the TimeMachine preferences pane on your client Mac to define your advertised volume as destination drive. ​ When prompted for a user name and password, use //tmuser// and the password set above. ​ TimeMachine will save your login information. 
- 
-===== Restore From Your Server ===== 
- 
-If the harddisk of your Mac dies and needs reinstallation through TimeMachine,​ your crippled Mac must first see your OpenWRT box. Boot your Mac with a DVD or similar, open a Terminal and type  
-<​code>​mkdir /​Volumes/​TimeMachine 
-mount -t afp "​afp://<​your OpenWRT route>/​TimeMachine"​ /​Volumes/​TimeMachine 
-</​code>​ 
- 
-You can then use TimeMachine to read back all your saved data from the remote drive. 
- 
-FIXME (fix mounting commands to work with username:​password) ​ 
- 
-===== Restore from the USB Disk ===== 
- 
-Since the USB disk was formatted using the HFS+ format, umount it from the router and plug it in directly to your Mac for a faster restore. 
- 
-<​code>​ 
-/​etc/​init.d/​afpd stop 
-umount /​mnt/​TimeMachine 
-</​code>​ 
- 
-When finished, plug it back into the router and restart Netatalk: 
- 
-<​code>​ 
-/​etc/​init.d/​afpd start 
-</​code>​ 
- 
-===== Recovery from Disk Errors ===== 
- 
-FIXME If the backup process is interrupted,​ the database can become corrupt and unusable. ​ Time Machine will report that the backup is unusable and will suggest creating a new backup. ​ Need to add a section to cover how to properly set up the time capsule so that it automatically and robustly recovers from these errors. 
timemachine.1368384365.txt.bz2 · Last modified: 2013/05/12 20:46 (external edit)