Cloud backup with MCrypt and S3cmd

Put a Sock in It

A tool called Trickle [6] lets you segregate your precious bandwidth and stop S3cmd from hogging your Internet connection. To take control of your bandwidth, install the natty little third-party package with:

# apt-get install trickle

This superb utility is a userspace bandwidth-shaping tool that you can plug in to lots of applications. Apparently, the excellent Trickle cannot affect all bandwidth services but, rather, only those programs speaking to the network that use dynamic libraries (thanks to glibc), and it doesn't play nicely with packages that are linked statically.

Fret not, because you can check against the shared library dependencies of a piece of software using the ldd command as follows. If you get any results displayed when running this command, it's good news, and Trickle should get on with the binary. The first example of this command shows a positive hit, and the second shows that you're out of luck:

# ldd /usr/bin/ssh | grep => /lib/x86_64-linux-gnu/ (0x00007f69228de000)
# ldd /usr/bin/apport-bug | grep

If you're curious (and ideally not logged in as root, because you are being careful), try the following command-line quickie. This command gives you a quick look into the path /usr/bin to check for the programs that Trickle supports:

# cd /usr/bin
# for filelist in *; do ldd $filelist | grep; echo $filelist; done

I should mention at this point that v1.0.0 of S3cmd, which automagically appeared on my laptop from Ubuntu's repositories, didn't compile automatically with dynamic libraries. I did also have the libevent library installed as suggested. The makers of the fantastic utility say that it should nevertheless work, and it is worth trying a newer version (v1.5.0 as I write) and compiling from source.

To limit half a megabit (Mb) of download capacity to your Amazon S3 activities, use the -d switch:

# trickle -d 512 s3cmd get chrisfile.tar.gz.ncs3://aws-bucket-name

Conversely, you can choke the upload capacity with -u:

# trickle -u 512 s3cmd put binnie_linux.doc.ncs3://aws-bucket-name

I got an error when I first attempted to run Trickle. The fix was to spawn a standalone mode. To do this, just add -s to the command:

# trickle -s -u 512 s3cmd put cb_linux.doc.ncs3://aws-bucket-name

If all else fails, your other options for limiting bandwidth include the Throttle utility [7], as well as tc or iptables.

It's a Nice Place

Despite the somewhat heady mix of encryption methods available on Unix-like systems, the wide and varied selection provides enough choice for you to find the most efficacious tool for each job. I've attempted to demonstrate that, for some scenarios, you might want to use a built-in encryption system for ease (e.g., S3cmd supports GPG), and you might want to scrub your deleted files automatically and diligently by default. For compatibility reasons, on the other hand, you might want to use something old school like MCrypt, which works in all sorts of ways and is commonly adopted by PHP.

The mighty and ultra-reliable AWS storage service means you won't experience angst the next time you misplace a config file that you spent all morning getting to work.

I hope this article will encourage you to forge a creative solution to suit your own file backup needs.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Command Line – crypt

    If you just need to encrypt a file or two, a descendant of crypt can do the job. Which one you choose depends on your objective.

  • Duplicity Cloud Backup

    If you're looking for a secure and portable backup technique, try combining the trusty command-line utility Duplicity with an available cloud account.

  • Manage Amazon S3 with s3cmd
  • Charly’s Column: S3QL

    Sys admin Charly has been an enthusiastic amateur photographer for many years. Recently, he started worrying about something happening to his rapidly expanding photo collection. Can the cloud save the day?

  • Duplicati

    The free backup tool Duplicati simplifies the process of backing up data with cloud providers while at the same time protecting backups with strong cryptography.

comments powered by Disqus

Direct Download

Read full article as PDF:

Price $2.95


njobs Europe
Njobs Netherlands Njobs Deutschland Njobs United Kingdom Njobs Italia Njobs France Njobs Espana Njobs Poland
Njobs Austria Njobs Denmark Njobs Belgium Njobs Czech Republic Njobs Mexico Njobs India Njobs Colombia