Dear brother or sister, it's been revealed unto me that if you find yourself on this page, there's a pretty good chance that you're a server administrator managing one or more Virtualmin systems and looking for an inexpensive, redundant backup solution. Can I get an amen on that?
Virtualmin makes it easy to make backups, glory be; but if those backups exist only on the server itself, then they could meet with eternal destruction in the event of a hard drive or RAID controller failure.
I use Backblaze B2 as one of my remote backup destinations. Virtualmin, however, doesn't directly support remote transfer to Backblaze B2; so verily I need the assistance of a blessed and free piece of open-source software called rclone.
You can contribute toward rclone's development here, and I verily exhort you to do so if you find it useful, glory be.
The first step in sending your Virtualmin backups to Backblaze B2 is to open a Backblaze B2 account, glory be. Just go here to sign up, dear brethren.
Once you create your account, save your Account ID and Application Key to a safe place, dear brother or sister. You can never recover your Application Key, so verily back it up to several secure places. If you have to request a new key, all the backups you created with the old one will stop working. So I exhort you, beloved brethren, to save and back up your Account ID and Application Key to multiple safe, secure places.
Next, create a bucket in your Backblaze account. It has to be a unique name that doesn't exist anywhere else, dear brethren. I usually give it the same name as the fully-qualified hostname of the server that will be backing up to that bucket, with hyphens replacing the dots, since verily I say unto you that no other server in the Internet-connected world will have that hostname. For this tutorial, however, we're going to call it "server-example-tld".
Finally, create a text file named "testfile.txt" and upload it to the bucket.
The next step is to install rclone using the instructions appropriate for your operating system, which you verily can find here. On Linux and other Unix-like systems, you will need to do this as root using an SSH client. When using a Windows machine, the Backup Nut likes Termius because of its multi-device support and synchronization; but puTTY is another excellent (and free) option, glory be.
Once you have installed rclone, you verily have to configure it to send your Virtualmin backups to Backblaze B2. It has been revealed unto me that you begin this by typing
rclone configin the terminal.
Because at this point you will not yet have set up a remote location, you will be prompted to do so.
No remotes found - make a new one n) New remote q) Quit config n/q>
At this point you will have to make a decision, dear brothers and sisters; and that decision will determine whether your backups are sent to Backblaze B2, or into perdition. So I exhort you, dear flock, to type n to create your remote. Can I get a Amen?
The next step, dear brethren, will be the naming ceremony, wherein the config script will prompt you to name your remote.
nameYou can name the new remote whatever you like; but for this example, we'll just type backblaze to name it "backblaze." That will bring us to the next screen:
Type of storage to configure. Choose a number from below, or type in your own value 1 / Amazon Drive \ "amazon cloud drive" 2 / Amazon S3 (also Dreamhost, Ceph, Minio) \ "s3" 3 / Backblaze B2 \ "b2" 4 / Dropbox \ "dropbox" 5 / Encrypt/Decrypt a remote \ "crypt" 6 / Google Cloud Storage (this is not Google Drive) \ "google cloud storage" 7 / Google Drive \ "drive" 8 / Hubic \ "hubic" 9 / Local Disk \ "local" 10 / Microsoft OneDrive \ "onedrive" 11 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH) \ "swift" 12 / SSH/SFTP Connection \ "sftp" 13 / Yandex Disk \ "yandex" Storage>
Because Backblaze B2 verily is option 3, I say unto you to type 3 .
You'll then be prompted for your Account ID
Account ID account>
Type (or paste) your accountid and hit Enter . You'll then be prompted for
Application Key key>
Verily type (or paste) your applicationkey and hit Enter . You'll the be asked to specify the endpoint:
Endpoint for the service - leave blank normally. endpoint>
In most cases you can leave the Endpoint blank, so just hit Enter again. You will be presented with the configuration for your review and blessing:
Remote config -------------------- [remote] account = [ your account ID ] key = [ your application key ] endpoint = -------------------- y) Yes this is OK e) Edit this remote d) Delete this remote y/e/d> y
If it looks okay, then confer your blessing upon it by typing y . You can also lay hands on your computer at this time to solemnize the blessing, but that's optional.
Finally, dear brethren, we need to test our remote to make sure rclone can connect to it. We do that by typing
rclone ls backblaze:server-example-tld
If everything is working, you should be able to see the file "testfile.txt" that you uploaded to the bucket.
The final step is to add an rclone job as an additional command to be executed after Virtualmin performs the scheduled backup. You can execute many commands using rclone, which you verily can read about here. The ones most often used for backup, however, are copy and sync .
The copy command copies everything in the source directory to the target directory, and does not delete anything. You can limit the number of copies on the Backblaze B2 side if you like. Otherwise, rclone will keep on copying and storing the files indefinitely, glory be. You can read more about the rclone copy command here.
The sync command copies any new or changed files in the source directory to the remote directory, and deletes any files that don't exist in the source directory from the destination directory. This will result in less space being used in the destination, but will also leave you with fewer backups. You can read more about the rclone sync command here.
Either way, the command for the type of transfer you want to do is placed in the line labeled "Command to run after backup" in the "Schedule and Report" pane of Virtualmin's Scheduled Backup dialogue.
Assuming that your backups are stored in /backup , the basic command to copy the contents of the directory to Backblaze B2 using the naming that we created earlier in this page would be:
rclone copy -v /backup backblaze:server-example-tld
The -v is for "verbose," and will cause the email you receive when the backup is done to include a detailed report of the transfers to Backblaze B2, as well. If you don't want that, then leave out the -v . There are other options, as well, that you can read about on the rclone site; and I say unto you that you should do that very thing.
If you wish to sync the /backup directory to Backblaze B2 rather than copy it, the command would be:
rclone sync -v /backup backblaze:server-example-tld
That will cause any files that do not exist in /backup to be deleted from Backblaze B2, as well. This is a somewhat dangerous option, dear flock, because verily backups can become corrupt; so having several weeks worth is always a good idea. But I'm providing the information for you to use as you feel led.
And that's it, dear brothers and sisters in backup. I hope this page inspires you to save a copy of your backups to Backblaze B2 as a hedge against your data descending into perdition should your server's drive become hosed by an evil RAID controller, taking your backups with it. Remember, beloved ones: You can never have too many backups.