Mounting B2 Backblaze as a local filesystem using S3 proxy and Goofys
Recently I've been having some fun with B2's Backblaze platform - it's an S3 competitor which is a lot cheaper. I was very excited to try the service out but soon I realized there's not as many tools available to work with B2 unlike S3.
After some research I came across the S3 Proxy project. As the name implies, using S3 proxy allows you to access other storage backends using S3 compatible tools - such as Goofys.
In this post I will demonstrate how I used Goofys to mount my B2 bucket - aptly named "Lampros".
Note: This post assumes that you have already installed Docker.
1. Get the S3 proxy docker image:
docker pull andrewgaul/s3proxy
2. Run the S3 proxy and set it up for Backblaze B2 authentication:
docker run \
--publish 8999:80 \
--volume /media/b2_backblaze/:/data \
--env LOG_LEVEL="trace" \
--env S3PROXY_ENDPOINT="http://127.0.0.1:8081" \
--env S3PROXY_AUTHORIZATION="none" \
--env JCLOUDS_PROVIDER="b2" \
--env JCLOUDS_IDENTITY="replace_with_b2_account_id" \
--env JCLOUDS_CREDENTIAL="replace_with_b2_application_key" \
--env JCLOUDS_ENDPOINT="https://api.backblaze.com" \
Note the line '"S3PROXY_AUTHORIZATION="none"' - This means that there's no need to provide any credentials to Goofys since the S3 proxy is already handling the authorization to B2.
3. Get Goofys and move it to /usr/local/bin/goofys:
curl -LO http://bit.ly/goofys-latest
sudo mv goofys-latest /usr/local/bin/goofys
sudo chmod +x /usr/local/bin/goofys
4. Create a mountpoint and change ownership to the user of your choice - in this case I'm using my own user "lampros" and the mountpoint is /media/b2_backblaze:
sudo mkdir -pv /media/b2_backblaze
sudo chown -R lampros:lampros /media/b2_backblaze
5. Use Goofys to mount Backblaze B2... as an S3 bucket:
goofys -f --debug_fuse --uid=1000 --endpoint http://127.0.0.1:8999/ Lampros /media/b2_backblaze
Explanation of the above:
-f = run in foreground
--debug_fuse = will show you additional FUSE debugging
--uid=1000 = tell Goofys to set the ownership of the files in the bucket to uid 1000 - in this case the user "Lampros"
Lampros = the name of my Backblaze B2 bucket
/media/b2_backblaze = the mountpoint I created on step 4