One of my favorite utilities on the Linux command-line, and block storage is one of my favorite features on Linode’s platform, so in this article I get to combine both of these together – because what I’m going to be doing is show you how to use rsync to copy data from one server to another, in the form of a backup. What’s really cool about this, is that this example will utilize block storage.
Note: I’ll be using the Nextcloud server that was set up in a previous article, but it doesn’t really matter if it’s Nextcloud – you can back up any server that you’d like.
Setting up our environment
On the Linode dashboard, I created an instance named “backup-server” to use as the example here. On your side, be sure to have a Linode instance ready to go in order to have a destination to copy your files to. Also, create a block storage volume to hold the backup files. If you don’t already have block storage set up, you can check out other articles and videos on Linode’s documentation and YouTube channel respectively, to see an overview of the process.
Again, in the examples, I’m going to be backing up a Nextcloud instance, but feel free to back up any server you may have set up – just be sure to update the paths accordingly to ensure everything matches your environment. In the Nextcloud video, I set up the data volume onto a block storage volume, so block storage is used at both ends.
First, let’s create a new directory where we will mount our block storage volume on the backup server. I decided to use /mnt/backup-data:
sudo mkdir /mnt/backup-data
Since the backup server I used in the example stores backups for more than one Linode instance, I decided to have each server back up to a sub-directory within the /mnt/backup-data directory.
sudo mkdir /mnt/backup-data/nextcloud.learnlinux.cloud
Note: I like to name the sub-directories after the fully qualified domain name for that instance, but that is not required.
Continuing, let’s make sure our local user (or a backup user) owns the destination directory:
sudo chown jay:jay /mnt/backup-data/nextcloud.learnlinux.cloud
After running that command, the user and group you specify will become the owner of the target directory, as well as everything underneath it (due to the -R option).
Note: Be sure to update the username, group name, and directory names to match your environment.