Introduction

Samba AD currently doesn't provide support for SysVol replication. To achive this important feature in a Multi-DC environment, until it's implemented, workarounds are necessary to keep it in sync. This HowTo provides a basic workaround solution based on Osync.

Information on Osync replication

This HowTo describes a solution for SysVol replication based on Osync, which uses rsync to give two way sync between systems. This howto covers the bidirectional synchronization of two DC servers.

This solution has the following advantages:

setup is fast

configuration is very easy

Can work with windows (Windows can be used as master using the MinGW environment)

Osync also does backups and soft deletes which will keep a copy of deleted files and folders in a subfolder named .osync_workdir.
Unless you have specific reasons to do so, leave these options enabled.
Osync will an send email alert if there is a problem.

Setup on DC2

On DC2 Install rsync by using your package manager or compile from source. Make sure you use a version that supports extended ACLs!

1st Try

Before starting, make a backup of your sysvol just in case.

/usr/local/bin/osync.sh /etc/osync/sync.conf --dry --verbose

If this runs successfully, you may remove the --dry option and run again.

/usr/local/bin/osync.sh /etc/osync/sync.conf --verbose

Add to Crontab on DC1

Warning: Make sure that the destination folder is really your SysVol folder, because the command will replicate to the given directory and sync everything in it that isn't also on the source! You could damage your system! So check the output carefully to see if the replication is doing, what you expect!

Problems when you try to sync the folder

Warning: Please follow the steps below OR you can end up with an empty sysvol folder.

Disable the Cron command on DC1 by running 'crontab -e' and adding a "#" at the start of the osync line.

Check if rsync or osync is currently running with 'ps -aux | grep sync', if yes, wait for it to finish OR kill it (if it is zombie)

Remove the .osync_workdir hash files on both DC1 and DC2 at '/usr/local/samba/var/locks/sysvol'

Now check your sysvol and resync

Confirm that everything is working again

Re-enable the Cron on DC1 again

FAQ

How can I do this on windows?

Install the MSYS bash environment (read the osync documentation), then you may run osync as master from Windows.

What to do if I've more than one DC?

By Theory, You would just make a cron job on DC1 for every other DC you have and the complete sync will be perform next sync to all other servers. (Not tested)

Something like:

DC1 <> DC2

DC1 <> DC3

DC1 <> DC4

DC1 <> Any other DCs you may have

Why can't I simply use a distributed filesystem like GlusterFS, Lustre, etc. for SysVol?

A cluster file system with Samba requires CTDB to be able to do it safely. And CTDB and AD DC are incompatible. Please check on the reply from Samba Developer on the mailing list .

osync logs that an error email was sent, but it wasn't received.

This is being looked into and appears to be because the smtp server on the DC isn't set up correctly.

Why is the 'REMOTE_RUN_AFTER_CMD' commented out in the sample conf above ?

There is a problem with sysvolreset at present, once this is fixed, the comment will be removed, along with this question.