Tuesday, May 14, 2019

Synchronizing folders, configurations, programs, local server and database on 2 debian machines

I am using debian both on a laptop and inside a virtual machine on another computer.


I want to be able to synchronize those 2 systems in both ways so that I can



  • do some work say on the VM, then move to the laptop, synchronize and work further from there,

  • come back on the VM, synchronize and work further on...


After some googling, it looks like the tool that I need is Unison because, among others, of its 2-way synchronization feature.


What I am wondering now is what / what not and how to synchronize between the 2 machines.


I figured out that there are, in my case, basically 3 main points to consider (I may have forgotten something though):



  • synchronizing most (all?) of the content of the home folder, because from there I need the files that I work on, the bash aliases, the configuration settings of most programs (which I would like to be the same between the 2 machines), my home baked scripts, etc.

  • synchronizing the content of the local apache server and mysql databases that I run there to test locally some websites that I build (in order to be able to test locally on each machine separately / independently)

  • synchronizing the installed programs accross those systems.


So first, regarding the home folder, I thought that simply synchronizing the whole home folder would be a good idea. But looking at it more closely, it looks like some hidden files / directories on the VM are not present hence required on the laptop (eg. .vboxclient-clipboard.pid, .vboxclient-display.pid...) and vice-versa.


I was also wondering about some hidden files that seems to be specific to each machine (.cache, .dbus, .gconf)


Therefore, I was wondering if there were general rules (exclude some specific file extensions or known files / folders) that I could apply to ensure that I don't copy single system specific files and really stick to what I need and to what is common to the 2 machines (my data and config files such as the custom list of servers for filezilla).


Then, regarding the synchronizing of the local server and the mysql database, I thought that



  • I could synchronize the /var/www/ folder between machines with Unison as well (though it my not be a good idea)

  • I would need to write a script to dump, compare and if needed replace the mysql databases everytime (sounds really unefficient though)


Finally regarding programs, it looks like I would have to install manually those that were installed on one but not on the other (but this should not be a problem since I just need to do this when setting up the machines and I rarely install new programs thereafter).


On top of all of this, I am thinking about reinstalling debian on each of those 2 machines so I was also wondering if during the debian installation, it would matter if I would choose, on the each machine, different settings regarding:



  • disk encryption: basically I would like to encryp the disk using LVM on the laptop but I won't need this on the VM,

  • hostname: it is not criticall as I can use the same hostname on both machine but I was wondering if I could have 2 different ones (eg. debianlaptop and debianvm)

  • user passwords: I would use the same user names on both machines but different passwords (also for root) would be nice

  • software selection: I would definitely install those on both machines: "Debian desktop Environment" (with xfce as dektop manager set at the beginning of the installation), "Web server", "Standard system utilities" but I am wondering if it is really needed to install "Laptop" on the VM and if it impacts the synchronization.


For all of the above, my main concern is to be able to do the best choices so that



  • I can synchronize between the two in the most automatic way, with less manual intervention as possible (basically just running unison on the machine I am starting to work, and eventually taking care of some program installation and database synchronisation)

  • I synchronize only what is needed, avoiding files / folders / options that are system specific or that could overwrite system specific settings, leading to unwanted consequences...

No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...