How to Access S3 Buckets from Windows or Linux – ITPro Today

S3, Amazons cloud-based object storage service, is designed primarily for storing data that is used by applications running directly in the cloud. However, there are situations where you may want to access S3 buckets directly from your PC. You might want to do this to upload files from your PC to S3 without using the AWS Console, for example. Or, you may want to be able to monitor changes to S3 data from an application running on your local PC.

For purposes such as these, being able to access S3 data directly from your PC comes in handy. This article explains how to make S3 files available locally on both Windows and Linux using rclone, a free and open source tool for syncing cloud storage to local computers.

There are various other tools available for achieving this goal. I like rclone, however, both because its open source and because it works with any major operating system. Although there are some minor differences in the way you use the tool to access S3 data on Windows as compared to Linux, the basic process is the same regardless of which operating system youre running.

Following are the steps for using rclone to access S3 data from Linux or Windows.

Installing rclone is quite simple. You can download it for Windows or any version of Linux. On most Linux distributions, you also have the option of installing directly from your package manager using a command such as the following (for Ubuntu):

Or, you can download and run a Bash script to install rclone for you:

The latter approach may be desirable if you want a later version of rclone than the one offered in your distributions package repositories; otherwise, its better to use an official package from the repositories, because rclone will then be updated automatically for you whenever a new package version becomes available.

Rclone is a command-line tool, so youll need to open up a command shell or terminal to run it.

Once in the shell, you can run rclone directly with a simple rclone (or rclone.exe on Windows) command if the application is in your path--which it probably is if you installed it on Linux using a package.

If instead you just downloaded rclone as a ZIP file, you will have to unpack it, then use the cd command to navigate to the directory where the rclone files are located.

Once there, a simple ./rclone config (on Linux) or .rclone.exe config (on Windows) will start the program.

Rclone will then ask you a variety of configuration questions, including your AWS credentials for the S3 bucket you want to access. The configuration data will vary depending on how your S3 bucket is set up, but in general the default options should work.

After youve completed configuration, youre ready to use rclone to access S3 buckets.

Rclone offers about a dozen commands that you can use to interact with S3 data. For example, to list the contents of a bucket, use the ls command:

(If youre on Windows, replace rclone with rclone.exe.)

In this example, bucket-name is the name of your S3 bucket.

Likewise, to copy a file, use the copy command:

A full list of rclone commands is available on the rclone website. Keep in mind, however, that not all of them will work with S3 data. For example, you cant use the mkdir command (which would create a new directory) with an S3 bucket because S3 doesnt support directories.

Rclones built-in commands for interacting with data are handy if you just need to copy or access some files manually. But what if you want to automate interaction with your S3 data, or access it using commands that are not supported by rclone?

In that case, you can use the rclone mount command to mount your S3 bucket as a directory. That way, you can interact with your S3 data just as you would any other data stored locally on your computer.

To mount an S3 bucket with rclone on Linux, use a command like:

Note that you may need to run this command as root. Youll also need to make sure the mount point (/mnt/some-dir in the example above) exists before you run the command. (If it doesnt, use mkdir on Linux to create it.)

The process is similar on Windows, with one major difference: You first need to install WinFsp (find the installer here) before you can mount an S3 bucket. Once WinFsp has been installed, you can mount your S3 bucket as a directory with:

In this case, your mount point (C:somedir in the example) should be a directory that does not yet exist.

Whether you use Windows or Linux, rclone offers a free and straightforward way to access S3 buckets from your local computer. However, there are some caveats to keep in mind.

One is that Amazon charges you a fee every time you create or modify a file in an S3 bucket. This means that, if you perform a large number of file operations via rclone on S3 data, you may end up with a substantial cloud bill.

A second consideration to weigh is that the performance of your S3 data when you access it from your PC may be limited due to network latency. Even if you mount your bucket as a local directory, expect a delay when you interact with the data.

For both of these reasons, you may end up shooting yourself in the foot if you try to use S3 buckets as a cheap way to back up all of the data from your PC, or as a personal file-sharing service. In other words, dont try to use the method described above to turn S3 into something like Dropbox or Google Drive, which are better suited to situations where you need fast, cost-efficient integration between your local file system and cloud storage. Even though accessing S3 data from a local computer is relatively easy, the performance and cost implications make it impractical to do this on a large-scale or recurring basis.

Still, if you need a fast and simple way to access S3 data from your computer in order to copy files or use a certain application on a one-off basis, rclone makes it easy to do so on Windows, Linux and virtually every other operating system you can find.

View post:
How to Access S3 Buckets from Windows or Linux - ITPro Today

Related Post

Comments are closed.