Bidirectional Rsync/Unison based SysVol replication workaround
Introduction
WORK in Progress
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 rsync and unison.
Information on unison + rsync replication
This HowTo describes a solution for SysVol replication, that is based on rsync and unison. As Compare to the rsync method, it is bidirectional. But this howto only cover two DC setup.
It have the following advantages:
- setup is fast done
- configuration is very easy
- Can work with windows (Please add in)
We will use rsync through a SSH tunnel.
Setup the SysVol replication
Installation script
If you are using apt package manger you can try this script [1]
Please thank L.v. Belle for creating this
Make Change to the following to fix your need:
SETSAMBASYSVOLBASE=/var/lib/samba SETSAMBASYSVOLPATH=/var/lib/samba/sysvol ## in Minutes SETCRONTIME=5 SETCRONFILE=/etc/cron.d/sysvol-sync SETIPDC1="" SETIPDC2=""
Run it ./3-setup-sysvol-bidirectional.sh
Manually
Setup on the Domain Controller with the PDC Emulator FSMO role
- Install rsync by using your package manager or compile from source. Make sure, that you use a version that supports extended ACLs!
- We don't need to setup rsync server.
- Install unison by using your package manager or compile from source.
Creating SSH Public Key and ssh-copy to DC2
ssh-keygen -t dsa ssh-copy-id -i ~/.ssh/id_dsa.pub root@dc2
You can try to access DC2 via ssh ssh $SETIPDC2
Setup on all other Domain Controller(s)
- Install rsync by using your paket manager or compile from source. Make sure, that you use a version that supports extended ACLs!
- Create a password file /usr/local/samba/etc/rsync-sysvol.secret and fill it with the password you set on the PDC for the sysvol-replication rsync account (permissions of that file must not be world-readable!):
pa$$w0rd
- For replicating the SysVol folder, run the following command (--dry-run means that no modifications are actually made):
# rsync --dry-run -XAavz --delete-after --password-file=/usr/local/samba/etc/rsync-sysvol.secret rsync://sysvol-replication@{IP-of-you-PDC}/SysVol/ /path/to/your/sysvol/folder/ receiving file list ... done created directory /usr/local/samba/var/locks/sysvol ./ samdom.example.com/ samdom.example.com/Policies/ samdom.example.com/Policies/{31B2F340-016D-11D2-945F-00C04FB984F9}/ samdom.example.com/Policies/{31B2F340-016D-11D2-945F-00C04FB984F9}/GPT.INI samdom.example.com/Policies/{31B2F340-016D-11D2-945F-00C04FB984F9}/MACHINE/ samdom.example.com/Policies/{31B2F340-016D-11D2-945F-00C04FB984F9}/MACHINE/Registry.pol samdom.example.com/Policies/{31B2F340-016D-11D2-945F-00C04FB984F9}/USER/ samdom.example.com/Policies/{31B2F340-016D-11D2-945F-00C04FB984F9}/USER/Documents & Settings/ samdom.example.com/Policies/{31B2F340-016D-11D2-945F-00C04FB984F9}/USER/Scripts/ samdom.example.com/Policies/{31B2F340-016D-11D2-945F-00C04FB984F9}/USER/Scripts/Logoff/ samdom.example.com/Policies/{31B2F340-016D-11D2-945F-00C04FB984F9}/USER/Scripts/Logon/ samdom.example.com/Policies/{6AC1786C-016F-11D2-945F-00C04FB984F9}/ samdom.example.com/Policies/{6AC1786C-016F-11D2-945F-00C04FB984F9}/GPT.INI samdom.example.com/Policies/{6AC1786C-016F-11D2-945F-00C04FB984F9}/MACHINE/ samdom.example.com/Policies/{6AC1786C-016F-11D2-945F-00C04FB984F9}/USER/ samdom.example.com/scripts/ samdom.example.com/scripts/logonscript.bat sent 124 bytes received 1064 bytes 2376.00 bytes/sec total size is 1207 speedup is 1.02 (DRY RUN)
- Warning: Make sure that the destination folder is really your SysVol folder, because the command will replicate to the given directory and removes everything in it that isn't also on the source! You could damage your system! So check the output carefully if the replication is doing, what you expect!
- If everything looks sane, run the command without the --dry-run option and let rsync do the replication.
- To automate synchronisation, you can run the command via cron (e. g. every 5 minutes).
*/5 * * * * rsync -XAavz --delete-after --password-file=/usr/local/samba/etc/rsync-sysvol.secret rsync://sysvol-replication@{IP-of-you-PDC}/SysVol/ /path/to/your/sysvol/folder/
- Repeat these steps on every DC (except your PDC!).
FAQ
- How can I get multi-direction replication ?
- There are some testing using unsion with rsync to archive this.
Please check this installation script https://secure.bazuin.nl/scripts/3-setup-sysvol-bidirectional.sh
- 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.