David David - 10 days ago 4
MySQL Question

XAMPP on Google Drive

I've recently had to reinstall XAMPP onto my PC, which means another pain of having to replace any config files I had previously set up and any other data files (such as MySQL databases, websites etc).

I've done as much research into this as possible - but most people only seem to want to sync their htdocs and mysql data, however, I want to store the whole xampp installation on Google Drive, meaning no more having to set it up on other computers etc.

Is it possible? Advantages/disadvantages?

If XAMPP isn't recommend, would a seperate installation of apache/mysql/php on google drive be sufficient?

I have two ideas of how to go about this:


  • Install the USB Portable version on google drive

  • Install the full version on PC, then move it to google drive and symlink the location to the drive folder



I realise it may not be possible to run services with it... but other than that, I won't be accessing it from more than one PC per time, it's purely for the ability to have a server ready to use whether I'm on my laptop, PC etc... No more needing to copy over websites or change config files on both to match the needs of any new sites.

Thank you!

Answer

I figured this out myself quite a while ago, but I just remembered to post the answer in case anyone else wants it too.

TL:DR; = While it is possible, it's quite pointless / more overhead than needed.

The solution:

What I ended up doing was syncing the areas that were most important, these were (under the xampp root):

  • /htdocs
  • /phpmyadmin
  • /php
  • /mysql/data - Key thing here is not the whole folder, just the data bit

This ensures the versions of PHP and phpMyAdmin I have running are all the same, and that my databases are present (yay, no more export/imports!).

The reason I do not sync the apache folder is because my setup on my machines is slightly different (different paths).

I used symlinks to point the folders to their locations on Dropbox (Yes, I did ask for Google Drive, but see end of answer for why the swap).

It works quite nicely, and I haven't found a better solution. Although there is a shift of moving workflow onto Virtual Machines now, I need this portability more due to how much I have to switch between my laptop and my main PC.

Issues:

  • I encountered a few minor issues, nearly all with mysql.
    • MySQL service won't always start on machine boot if it's syncing files when it tries to load, not a major issue but a tiny nuance.
    • Corrupted databases! :-o This was actually more-or-less fixed by moving to Dropbox from Google Drive, more on this at end.
    • You can't reliably have both machines on at the same time, as it can cause conflicts in the database. When creating a new database, it's best to do it on one machine, let it fully boot up, then shut down the machine and boot the other one so it syncs in the required stuff. Sometimes the MySQL service will have to be stopped first.

Google Drive vs DropBox

I love Google Drive, I used it for everything. It's cheap, with like $3 for 100GB of space or whatever in comparison to the $10(£10?) of DropBox.

After a while, as my projects grew and my htdocs became massive, I started noticing several issues. I started using a framework called Laravel 4 for a while, this involved a lot of files being brought into the vendor directory by composer. Google Drive seemed to index part of it and then only sync some of the files, but without me realising.

This would result in me going to my laptop a while later, usually away from my PC, and realising half my project was missing and thus unusable. The files in most cases wouldn't be picked up unless I deleted the whole folder or some other trickery, which was quite a pain on initial project creation.

I also found the database corrupted far too often when using Google Drive, as the amount of files in the Google Drive folder increased, the worse it got.

Eventually, I decided to swap my htdocs to DropBox. After having no issues for weeks, I swapped the rest over, ever since then I've had no issues with the database corrupting or any folders not being synced. I think this may be down to Google Drive seemingly not able to handle so many small files (as a rough estimate, Laravel 4 vendor directory has 4k+ files, imagine this on like 10 projects plus any other projects not on laravel 4...).

Tackling database corruption

While still using Google Drive I found a safe way to make sure my databases more or less were safe even if corrupted, I created a batch file (Yup, windows user) to do a database backup of all non-default databases (skipping the ones that come with MySQL / PhpMyAdmin basically) to a .sql file in a folder not on Google Drive/DropBox. That means if my database did corrupt, the worst that happens is I've lost a days work on the database, which usually does not amount to much (especially if you use migrations to create tables). It's just a simple task of dropping the corrupted tables/databases and restoring them through the .sql file.

Comments