I’m sure you never found yourself in a situation where you need to backup something when you don’t have the space to do it 🤣. Some context. For the past few years I’ve been running a cheap $5/month Digital Ocean droplet. It wasn’t anything too mission critical. Combine that with the fact that I may have forgot to setup automated backups. Fast forward, now the server is over 80% full of disk space, all related to the ever growing database. Simple things like running a database dump aren’t possible due to lack of space. What now?
Rclone mount
to the rescue!
This nifty little trick saved the day. Start by downloading and installing Rclone. Then configure a SFTP provider. For me that was adding in SFTP info for the new VPS replacement. Next mount that remote server to an empty folder locally. This needs to be done in a background session so that you can run other commands while the mount is happening. I recommend using screen
to handle that like this:
screen -R
mkdir -p ~/Tmp/mount
rclone mount sftp-new-vps: ~/Tmp/mount
Next type ctrl + A + D
to detach from that screen session. You should see a local folder ~/Tmp/mount
which contains files on new VPS. Putting anything into this mounted folder will place them on the remote server. You can even run a mysqldump
directly into this folder and like magic, it won’t use up any local storage. The backup is created, transferred and stored remotely in real-time.
mysqldump -u $DATABASE_USER --password=$DATABASE_PASSWORD $DATABASE_NAME > ~/Tmp/mount/database.sql
Once completed, reconnect to the background session using screen -R
and close the mount ctrl + c
. Another day saved with Rclone.