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.
Conclusion
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.