WordPress as an Experimental Rclone HTTP Remote

Whenever I migrate WordPress sites I prefer that to be handled by a command line script. Well that’s not always possible often due to limited access on the source WordPress site. Many times I’m only giving WordPress admin access and work with that.

My go-to has been to use a backup plugin.

But still, wouldn’t it be amazing if all of that could all be scripted. When that thinking lead me down rabbit trail wondering if Rclone could directly talk to WordPress. The idea was too good I just had to see how far I could take it πŸ‘¨β€πŸ’». The following is the result of a weekend experiment.

If you’re not using Rclone, you’re missing out.

Rclone is an amazing command line tool for moving data to and from virtually any cloud provider. I currently use it to incrementally sync my WordPress sites to B2 cloud storage via SFTP in a daily backup script.

Can Rclone work without SFTP/FTP login info?

Rclone supports an HTTP remote which basically means it can fetch files from a website that has a public file directory. Well WordPress for obvious security reasons doesn’t expose files publically. However with a clever PHP script, it would be technically possible. πŸ’ͺ

How I imagine Rclone could work with WordPress

This is what I’d imagine would be the killer Rclone & WordPress setup.

  • Add WordPress plugin to enable Rclone HTTP remote. (should generate some unique path to copy into rclone)
  • Add site to Rclone locally
  • Run rclone sync

Let the experiment begin!

I haven’t written many WordPress plugins. Just a few for personal projects. For a quickstart I used wppb.me to generate a boilerplate plugin. Next I hacked together a PHP protection script which I used on a past project and modified it to serve all files at a very specific URL path for Rclone to digest. Rclone works by reading common directory lists from web servers like Apache and Nginx. I copied some sample html output from a default Apache directory list and feed in all files starting at the WordPress root using a few PHP functions I found on this blog. I never really like the default WordPress admin page so I did my own Vue.JS page which allows you to enable the remote.

So does it work?

Well sorta. This is probably best explained in the following walkthrough video.

Video Thumbnail
Rclone Remote Overview
https://github.com/austinginder/rclone-remote

Workarounds and known issues make it impractical to use.

It’s a bit too cumbersome and slow to use in its current form. If you don’t have FTP access just install BackupBuddy rather attempt to use Rclone via PHP. That said I do think some of the main limitations could be overcome with a few enhancements to Rclone itself. I’ll leave that to someone else to tackle or maybe an adventure for another day. πŸ˜…

Source code is on Github: https://github.com/austinginder/rclone-remote.