Keeping config files synced across multiple pc’s

configurationsynchronization

I have a few different linux machines and a lot of config files (and folders) on each.

For example:

~/.ssh/config
~/.config/openbox/rc.xml
~/.config/openbox/autostart.sh
~/.scripts/ ( folder )
~/.bashrc
...etc

Is there a simple and elegant method to keep these files synced between my machines ( one has no internet access )?

Also, some files will need a more advanced syncing process, as they will have to differ slightly… for example:

My desktop keyboard has a range of hotkeys, where my laptop has almost none. I use XF86Mail to open thunderbird on my desktop, but Meta+M on my laptop.

My Home Desktop and Work Desktop are both more "multiple user" orientated, where my Laptop is just for me. So on my laptop, I tend to keep the 'rc.xml' file for openbox at /etc/xdg/openbox/rc.xml but on the desktops at ~/.config/openbox/rc.xml

Best Answer

Keep the files under version control. This has multiple benefits, including facilitating keeping files synchronized (commit on one machine, update on the others) and keeping a history of changes (so you can easily find out what broke a program that worked last month).

I use CVS and synchronize the repositories with Unison or sneakernet, but that's because I've been doing this since a time before widely-available distributed version control. Anyone starting now should use a proper distributed version control tool, such as bazaar, darcs, git, mercurial, ...

Managing files that need to differ between machines is always a bit of a pain. If the configuration language allows conditionals, use them. Otherwise, if there is an include mechanism, use it to split the configuration file into a machine-dependent part and a shared part. Keep all the machine-dependent parts in a separate directory (something like ~/.local/NAME/) which is always referred to through a symbolic link (~/.here -> local/NAME on each machine). I have a few files that are generated by a script in the shared part from parameters kept in the machine-specific part; this precludes modifying these files indirectly through a GUI configuration interface. Avoid configuring things in /etc, it's harder to synchronize between machines.

Related Question