1

How do I copy (down) a Rackspace Cloud File bucket to a local directory? Or better yet, how do I update a local directory to be a copy of the RS bucket?

There are plenty of tools for uploading or "rsync"ing up, but I am looking for a tool which copies in the other direction (down from the server).

3 Answers 3

0

You don't make it clear whether this is a regular - systematic - requirement, or a one-off.

If the latter, and in certain circumstances the former, you should check out tools such as Expandrive or CyberDuck which allows you to synchronise a folder from a machine onto the Cloud Files container.

In terms of the latter (systematic requirement), I wouldn't recommend these client-side tools in the same way - you're better off scripting something yourself using the API. Matt has given a good answer about Pyrax - obviously do check out similar API bindings in other languages if required - the full list is in the docs, here.

1
  • Systematic, on-going -- not a one-off. We ended up rolling our own. Oct 17, 2013 at 3:38
1

You can download a container recursively, i.e. including sub-folders and their contents, using openstack/swift tools. On ubuntu, the tools can be installed with apt-get install python-swift

Then change into the directory where you want the contents to be downloaded to and run

swift -A https://auth.api.rackspacecloud.com/v1.0 -U <username> -K <api-key> download <container-name>

Then the contents of the <containername> container will be downloaded to the current directory. You need to supply the <username> you use to log in to the Cloud Control Panel and the <api-key> available under Account / Account Settings in the same control panel.

0

Dwayne,

I don't know of any existing applications that will do this, however using the official Rackspace Python SDK, pyrax we can achieve your goal. pyrax does not contain fully built out functions required to perform this, but I spent a few minutes and put something together by extending the default functionality of pyrax.

You can find the code at https://gist.github.com/5602713

At the very bottom of the code, you would need to update myusername with your real username, myapikey with your real api key, the 2 places with the appropriate region (which may already be DFW), some-container with the real container name, and /path/to/some/local/directory/ with the local directory you want it to sync down to.

The way that sync_container_to_folder is called towards the bottom of the script, will delete any local files that do not also exist remotely, working similarly to the --delete argument for rsync. You can add delete=False to prevent that functionality, such as:

     cf.sync_container_to_folder('some-container',
                                 '/path/to/some/local/directory/',
                                 delete=False)

The options for sync_container_to_folder are very similar to that for the built in function from pyrax, sync_folder_to_container, as documented at https://github.com/rackspace/pyrax/blob/master/docs/cloud_files.md#syncing-a-local-folder-with-a-container

I've tested on some small containers, nothing big, and can confirm it seems to be working well. But just to be safe, you may want to test things with a test container, and an empty local directory first.

BTW: You will need to install the pyrax module and the python-dateutil module to use this. These are not standard python modules.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .