Rsync based SysVol replication workaround

Revision as of 20:34, 23 July 2013 by Mmuehlfeld (talk | contribs) (Change link to script)


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 solution based on a script that uses rsync.

Like on every change/enhancement, it's highly recommended to test the procedure in a save environment and have a recoverable backup!


Group Policy Management Console option for PDC

This HowTo describes a way to setup rsync on your DC, that contains the FSMO role „PDC“. The script, that is used below to keep all other servers in sync, retrieves the content from the PDCs SysVol share via rsync.

If you prefer to use rsync through a SSH tunnel, you can adapt the script to your needs. But typically there's no confidential content on the SysVol share. It should be alright for most if the transfer is unencrypted. The rsync module on the PDC is also defined as read only, because it is used only as source. So no content can be pushed to it.

Because the SysVol share on your PDC is the source where all other DCs are pulling their content from, it is required, that you only do changes (e. g. GPO, logonscripts, etc.) on this server. Changes made on the other DCs are overwritten on every sync script run.

E. g. the Group Policy Management Console can be configured, to use the PDC to connect to. If you choose „Action“ / „Change Domain Controller“, you should select „The domain controller with the Operations Master token for the PDC emulator“ (should be already default), to do changes automatically on your PDC.

Setup the SysVol replication

Setup on the Domain Controller with the PDC role

  • Install rsync by using your paket manager or compile from source. Make sure, that you use a version that supports extended ACLs!
  • If you start your rsync-server through xinetd, you can use the following configuration file (/etc/xinetd.d/rsync):
service rsync
   disable         = no
   only_from       =     # Restrict to your DC address(es) or ranges, to prevent other hosts retrieving the content, too.
   socket_type     = stream
   wait            = no
   user            = root
   server          = /usr/bin/rsync
   server_args     = --daemon
   log_on_failure += USERID
  • Create the file /etc/rsyncd.conf (adapt the path variable to your PDCs SysVol path):
path = /usr/local/samba/var/locks/sysvol/
comment = Samba Sysvol Share
uid = root
gid = root
read only = yes
auth users = sysvol-replication
secrets file = /usr/local/samba/etc/rsyncd.secret
  • Create a file /usr/local/samba/etc/rsyncd.secret (permissions must not be world-readable!) with the following content (adapt the password!):
  • Restart xinetd.

Setup on all other Domain Controller(s)

It's suggested to test the script on a save place, to avoid any problems in production! The script comes without any warranty!

  • Install rsync by using your paket manager or compile from source. Make sure, that you use a version that supports extended ACLs!
  • Create a file /usr/local/samba/etc/rsync-sysvol.secret and fill it with the password, set on the PDC for the sysvol-replication rsync account (permissions of that file must not be world-readable!):
  • If you use a different rsync username than mentioned above and/or a different path to the rsync-sysvol.secret file, change it in the configuration area in the head of the script.
  • First run the script in dry-run mode:
# /path/to/ -d
  • The script auto-discovers the path to the local SysVol share through testparm. As the share is automatically setup in your smb.conf when joining as DC, this should work without any problems.
  • The PDC IP is auto-discovered through DNS (_ldap._tcp.pdc._msdcs.your.domain.). If you encounter any problems, you can define the PDC host by -p [IP].
  • If everything looks fine on the dry-run, you can start the real replication process:
# /path/to/
2013-07-23 21:05:24 **********************************************************************
2013-07-23 21:05:24 Auto-discovered PDC:
2013-07-23 21:05:24 Replicating from
2013-07-23 21:05:25      receiving file list ... done
2013-07-23 21:05:25      ./
2013-07-23 21:05:25
2013-07-23 21:05:25
2013-07-23 21:05:25{31B2F340-016D-11D2-945F- 00C04FB984F9}/
2013-07-23 21:05:25{31B2F340-016D-11D2-945F- 00C04FB984F9}/GPT.INI
2013-07-23 21:05:25{31B2F340-016D-11D2-945F- 00C04FB984F9}/MACHINE/
2013-07-23 21:05:25{31B2F340-016D-11D2-945F- 00C04FB984F9}/MACHINE/Registry.pol
2013-07-23 21:05:25{31B2F340-016D-11D2-945F- 00C04FB984F9}/USER/
2013-07-23 21:05:25{31B2F340-016D-11D2-945F- 00C04FB984F9}/USER/Documents & Settings/
2013-07-23 21:05:25{31B2F340-016D-11D2-945F- 00C04FB984F9}/USER/Scripts/
2013-07-23 21:05:25{31B2F340-016D-11D2-945F- 00C04FB984F9}/USER/Scripts/Logoff/
2013-07-23 21:05:25{31B2F340-016D-11D2-945F- 00C04FB984F9}/USER/Scripts/Logon/
2013-07-23 21:05:25{6AC1786C-016F-11D2-945F- 00C04FB984F9}/
2013-07-23 21:05:25{6AC1786C-016F-11D2-945F- 00C04FB984F9}/GPT.INI
2013-07-23 21:05:25{6AC1786C-016F-11D2-945F- 00C04FB984F9}/MACHINE/
2013-07-23 21:05:25{6AC1786C-016F-11D2-945F- 00C04FB984F9}/USER/
2013-07-23 21:05:25
2013-07-23 21:05:25
2013-07-23 21:05:25      
2013-07-23 21:05:25      sent 191 bytes  received 1908 bytes  1399.33 bytes/sec
2013-07-23 21:05:25      total size is 1207  speedup is 0.58
  • Run the script with the -h option for further information and parameters.
  • To automatically syncronize the SysVol share every 5 minutes incl. logfile creation, setup a Cron job:
*/5 * * * *     /path/to/ -l /var/log/sysvol-replication.log > /dev/null
  • Repeat this steps on every DC (except your PDC!).