Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

GKMelbo's avatar

How to sync two VPS block storage

Hi, I was wondering if anyone know of a good solution to keep two VPS block storage in sync?

My setup:

I have one Load Balancer. Two VPS from Digital Ocean, each in different countries with Block Storage connected for storing user uploads.

I'm going for a HA setup and therefore need a way to synchronize the two Block Storages in real-time.

I have looked at rsync, but it seems that works best if the sync is only one-way.

I appreciate any input!

0 likes
5 replies
ejdelmonico's avatar

You will have to write your own cron job to do it. I am not aware of any way to sync them because the block can only be attached to one VPS in the same data center. The block is replicated in the same center for high availability. An I think you can only have one connection to the block at a time. However, DO is rapidly developing more features for block storage. You might have a look at this article: https://medium.com/@jmarhee/building-an-object-storage-service-ecd771d91483

GKMelbo's avatar

@ejdelmonico Thanks for that article. The only downside I see in the article (for my needs) is that it uses temporary URLs to access data, just like aws S3. Which in my case would be a lot of client requests because of the users.

I trusted DO with the high availability for block storage, but after this incident: http://status.digitalocean.com/incidents/8sk3mbgp6jgl I would like to replicate everything to another region just in case something like that where to happen again.

ejdelmonico's avatar

Maybe create an ssh tunnel to the other server with attached block storage and sync the data every few hours with a cron job. That is all I can think of at the moment.

click's avatar

If you are going to sync two servers remember that you solve or prevent file name collisions.

Another solution could be:

  • Let users upload files on your application
  • Fire an event when a file is uploaded
  • Listen for the event and upload it to the other server(s)

This of course requires updates in your application.

GKMelbo's avatar

Thanks for the inputs everyone!

I discovered AWSs EFS storage, tried it, and it seems to be a good solution so I'm going with that.

Please or to participate in this conversation.