FreeNAS - Unison Syncing
Episode Number:
3 Show Notes and Links:
Setting up your Mac to sync to FreeNAS via Unison
Enable the SSH service on FreeNAS
- Open FreeNAS WebUI
- Click the Services tab, then select SSH
- Check the Enable box
Create and grant a user SSH access
- Click the Access tab, then select Users and Groups
-
If you need to create a new user, click the plus button
- Type the username in the name box
- Specify the password
- In the Shell drop-down box select the shell program you wish to use for the account. If unsure, select bash
- Click Add
-
In the Shell drop-down box select the shell program you wish to use. If unsure, select bash
Setting up your Mac to sync to FreeNAS via Unison
Enable the SSH service on FreeNAS
- Open FreeNAS WebUI
- Click the Services tab, then select SSH
- Check the Enable box
Create and grant a user SSH access
- Click the Access tab, then select Users and Groups
-
If you need to create a new user, click the plus
- Type the username in the name box
- Specify the password
- In the Shell drop-down box select the shell program you wish to use for the account. If unsure, select bash
- Click Add
-
In the Shell drop-down box select the shell program you wish to use. If unsure, select bash
If you wish to give the default guest account access, click the wrench icon (edit) for the guest account, or if you've already created a user account edit that one.
Create a Public/Private Key for automatic SSH authentication
- Open up terminal
- Run ssh-keygen
Create the .ssh folder in the user's home diretory
(i.e. homeuser's home directory is /mnt/raid_mnt/home_share)
- ssh homeuser@freenas.borns.local
- mkdir .ssh
- chmod 700 .ssh
Upload the public key to the .ssh folder
- scp ~/.ssh/id_rsa homeuser@freenas.borns.local:~/.ssh/authorized_keys
- ssh homeuser@freenas.borns.local
- cd .ssh
- chmod 600 authorized_keys
Assign the appropriate permissions for the FreeNAS mount point
(which should be dedicated solely to one user)
- Click the Disks tab, then select Mount Points
- Click the Edit icon for the mount point containing the sync directory
-
Change the User drop-down box to the user we've setup for sharing and shell access
- The Group drop-down box can be changed if you've setup a custom group as well
- Uncheck the Write checkboxes for the Other and Group sections for permissionsClick the Save button, then the Apply Changes button
Enable and configure the Unison Service
- Click the Services tab, then select Unison
- Check the Enable box
- Click the ... button (browse) for the Working directory field
- Browse the folders of the FreeNAS box and select the root folder you wish to keep synchronized
- Click the Save and Restart button
NOTE:
- The Unison working directory is stored in an environment variable in the /etc/login.conf file. There's a bug with making changes to the working directory: the variable is only appended with changes and not updated properly.
- To edit this file, you need to be root and you have to configure root to be able to log in via SSH
- Locate the UNISON= and delete the path(s) after it until you get to the :\ which signifies the end of the file. After this go back to the WebUI and do a quick "Save and Restart" under Unison and the value you have in the text box will be put back in.
Download and Configure Unison for the Mac
- Download and Install Unison
-
Download the Unison UI from http://alan.petitepomme.net/unison/index.html
- The latest version as of this document is 2.27.72 (http://alan.petitepomme.net/unison/assets/Unison-2.27.72.dmg)
- Mount the dmg file and drag the Unison application over to the Applications folder (or wherever you feel is appropriate)Install command line utility for cron jobs
- Open the Unison application
- With Unison selected, up in the menu bar, click Unison then Install command-line tool
- The program copies the program without granting access outside of the root account. We need to grant ourselves access
- Open Terminal
- Navigate to the install directory: cd /usr/bin
- Change permission mask: sudo chmod 755 unison
Create Unison Profile
- Click the Add button to create a new profile
- Give the profile a descriptive name, preferably the purpose of the profile, in the Profile name text box
- The First Root text box will be the local path to the directory you would like synced
- The Second Root is for the destination synch
- Make sure the Remote option is selected
- Type the username for the account given shell access to earlier in the User text box
- Give the IP/DNS address to the remote location in the Host text box
- Give the path to the folder you wish to syncrhonize
NOTE:
- There is no way to delete or edit profiles with the user interface. However, they are plain text files stored in the following location:~/Library/Application Support/Unison
- You can open the files within TextEdit (or other appropriate text editing software) and make any changes. You can delete the profiles and start over as well.
- This folder also contains the archive file that Unison uses to keep track of changes.
Video Download:
Video Download HD: