Archive for the ‘Open Source’ Category

WordPress Backup to Dropbox 0.8

26 May

After many late nights I am pleased to finally release WordPress Backup to Dropbox 0.8!

In this release I have significantly changed the way backups are performed in order to make the process more efficient, smarter and use less memory and bandwidth. The biggest problems that people have been reporting is the plugin “Does not work” or “Starts but no backup is appearing in Dropbox”. Firstly, let me assure you, that I tested the original version on few WordPress installations and all seemed fine, unfortunately, my sample size was too small and others have run into problems.

I managed to identify three major issues that contributed to failing backups.

Issue 1: Memory

Zipping large files in PHP can be quite memory intensive and the method I originally used read an entire file into memory before compressing it and adding it to the archive. So if your website contained a file that was approximately 50% the size of your PHP memory limit setting then the process would raise a fatal error. In version 0.7.2 I added a quick hack that increases this limit via the ini_set() function. Unfortunately modifying this setting is blocked when PHP is running in safe mode or the Suhosin Patch has been applied. The former of which is very common on shared hosts around the world.

The same issue applies when uploading a file to Dropbox which is bad considering that a websites archive can easily be quite large!

In this new version I have removed zipping altogether in favor of a smarter differential backup algorithm. Each file will now be uploaded individually if does not exist in Dropbox, or has changed on your sever since the last backup.  Of course, this will mean that your initial backup will be larger then that of a zipped archive, however all subsequent backups will only contain files that have changed thus decreasing bandwidth.

In addition I have added a warning system where, instead of failing, the algorithm will log a warning if an upload of a file fails. Currently a warning is raised if it encounters a file that will exceed the memory limit setting in PHP, the upload times out or there is an error connecting to the Dropbox server.

Issue 2: Safe Mode

A backup can take a very long time to complete so the plugin needs to set PHP’s max execution time to unlimited to get the job done. If your server has PHP compiled with safe mode enabled then there is no way this can be set in code. For more information please read the blog post I wrote about this problem.

If you are in this situation the plugin will now warn you that you need to manually set you max execution time to a larger value and  attempt to backup your WordPress installation. If the backup duration nears this setting then the backup will fail alerting you to the fact that it is has been set too low.

Issue 3: Your Host

The third major issue I encountered is the fact that some hosts, including my own, kill long running processes. So regardless of the setting you have set above if the process takes longer then the host allows it will be killed. To get around this I have introduced cron job to the plugin that will monitor the backup process to ensure it is still running. If the monitor notices that no activity has occurred in five minutes then a new backup process will be started resuming from where the last one failed.


In addition to these major fixes I have added validation of the paths and fixed a couple smaller issues to increase the stability of the plugin.

I hope this version will work for all, however there is no such thing as bug free code! So if you have any issues, rather then just giving the plugin a low rating or tagging it as broken, please let me know and I will endeavor to fix them.

Issues can be raised in the BitBucket issue tracker or the WordPress forum for my plugin.


Setting the maximum execution time and memory limit when PHP is running in safe mode

24 May

Many php applications, like WordPress Backup to Dropbox, require an extended max execution time and memory limit PHP settings in order to complete a task. By default the time setting is set to 30 seconds and, in the case of my WordPress plugin, is not enough for a backup to be completed.

If the PHP installation was not compiled in safe mode then a developer can temporarily change this value within a plugin using set_time_limit. So for any long running scripts setting the time limit to zero will tell PHP to allow the script to run forever.

However if your PHP installation is running in safe mode, this functionality is blocked and there is no way of altering the time or memory limit from within the application. Therefore the only way to get the an application to complete its task the php.ini max_execution_time and memory_limit setting will need to be altered. In the case of WordPress Backup to Dropbox this setting needs to be set to at least 3600 seconds  (1 hour) and at least 150M respectively.

How easily this value can be changes depends on how your hosts PHP installation is configured. If your host allows it you can put a file named php.ini inside the root and wp-admin folders of your WordPress installation with the settings set to

max_execution_time = 0
memory_limit = 150M

If this does not work then you have to edit the value in your php.ini file. The location of this file depends on your operating system and a quick Google search will yield plenty of literature on how this is done.


TortoiseHg review board interface now uses a fork of the original extension

29 Dec

I originally wrote the TortoriseHg review board user interface to use a fork of Mdelagra’s fork of the original mercurial extension.

I have since made some changes to the UI I wrote earlier this year ( to make use of a fork of the original extension instead.

I did this because the original extension that is listed on the Mercural website ( has recently been update to support the Review Board API 2.0 that was shipped with Review Board 1.5. This updated API has some nicer features that I have implemented, namely, the more granular control over filtering review requests.

So I have forked the original and, among a couple of bug fixes, added some features to make it play nicer with the TortoiseHg review board dialog. This fork is now required to be used with TortoiseHg and can be downloaded here –

I have made contact with the developers of the original extension and hope to get my changes merged into it some time in the new year.

Hopefully before the release of TortoiseHg 2.0, however in the mean time my fork will have to suffice.