rclone(1) as a bunny.net client
This post takes a look at using rclone as a bunny.net client on FreeBSD. bunny.net provide a content delivery network (CDN) and an object storage service that's both easy to use and affordable.
Both (s)ftp and HTTP are provided as upload options but finding an efficient and trustworthy client proved to be a challenge. I settled on rclone via sftp. For some context the static website I am hosting is made up of hundreds of directories and thousands of files that are updated semi-frequently.
pkg install
If you haven't already go ahead and grab the rclone package:
root@localhost# pkg install rclone
rclone config
Next we want to add a remote that will represent a storage zone on
bunny.net. To do this we
will run rclone config
and follow the instructions to add a
new remote.
The remote name is up to you, the storage type should be entered as 47
(sftp). The hostname varies by storage region, for example it might be
storage.bunnycdn.com
. See the list of storage endpoints for other options. The username and
password can be obtained from the "FTP & API Access" section of the
storage zone page.
rclone (copy|sync)
Once the remote is configured we can use rclone to upload files by
either syncing or copying them to the remote. The primary difference
between the two is that sync
deletes files that are no
longer present in the local copy, while copy won't delete anything.
These are the commands I use most often:
##
# rclone copy
$ rclone copy \
\
/var/nfs/website \
name_of_remote: --inplace \
--progress \
--transfers 8
##
# rclone sync
$ rclone sync \
\
/var/nfs/website \
name_of_remote: --inplace \
--progress \
--transfers 8 \
--exclude "*.mp4"
Conclusion
While looking for possible bunny.net clients I came across a handful of unofficial clients that looked obscure and I wasn't sure I could trust them. So in the end I was happy to find that rclone could be used as a client for bunny.net.
In closing, it is worth noting that I tried both ftp and sftp with rclone, and the sftp option was much faster and more reliable.