Sync/mirror directory with Rackspace Cloud files bucket

cloud-storagemirroringrackspace

What tool can I use to synchronize the content of a local directory with that of a Rackspace Cloud Files bucket?

I need a rsync-like application to do a mirror, not a backup application. What I want is the ability to do

rsync --update --delete /local/dir/ cloudfiles://bucket

so that the remote bucket contains an exact mirror of the files that are in /local/dir/.

The files' metadata (owner, permissions) is not important and there are no directories inside the main directory.

Best Answer

The easiest way to sync a local directory to Rackspace cloud files is through the console tools provided by the openstack/swift project. On ubuntu, the tools can be installed with apt-get install python-swiftclient

Then, assuming you are in the directory you want to upload, run the following command in the terminal:

$ swift -A https://auth.api.rackspacecloud.com/v1.0 -U <username> -K <api-key> upload <containername> . --changed

This will recursively upload the files from your current directory to the <containername> container, saving time by uploading only changed files. 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.

Attention: If you use relative or absolute paths, swift will upload them with the pseudo-path provided on the command line into the container. So if instead of syncing . you sync /var/www/test, then files will end up under /var/www/test pseudo-path of the container - most likely, this is not what you want.

Related Topic