My usual approach is to use
blueprint,
etckeeper, and/or [url=http://www.opscode.com/]chef to summarize the differences between a standard OS image and my ideal system, and
duplicity to back up data. But, this does take some planning and forethought, and restores will also take some planning. On the other hand, it is much easier to move to other providers and architectures. (See also
tarsnap, for something I haven't used but that looks nice.)
For sending stuff to S3, I find it's easier to use whatever you normally use to send stuff to S3. For me, it's s3cmd, but there's probably others out there.
In the interest of science, I just deployed a fresh Linode (with a 10 GB disk image -- I'm not made of money here, yo), booted up Rescue mode, and ssh'd to lish. Long story short, I couldn't make it work. My first attempt was to install s3cmd (apt-get update; apt-get install s3cmd; s3cmd --configure) and try to put the file. It returned immediately, having done nothing:
Code:
root@hvc0:~# s3cmd mb s3://awesome-bucket-of-science
Bucket 's3://awesome-bucket-of-science/' created
root@hvc0:~# s3cmd put /dev/xvda s3://awesome-bucket-of-science/disk.img
root@hvc0:~#
So I installed Boto 2.0 from the repository (apt-get install python-boto) and tried to upload that way. It, too, failed, but after doing much more:
Code:
root@hvc0:~# python
Python 2.7.2+ (default, Aug 16 2011, 07:03:08)
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from boto.s3.connection import S3Connection
>>> conn = S3Connection('<aws access key>', '<aws secret key>')
>>> bucket = conn.create_bucket('awesome-bucket-of-science')
>>> from boto.s3.key import Key
>>> k = Key(bucket)
>>> k.key = 'disk.img'
>>> k.set_contents_from_filename('/dev/xvda')
... a long pause here ...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/boto/s3/key.py", line 713, in set_contents_from_filename
policy, md5, reduced_redundancy)
File "/usr/lib/python2.7/dist-packages/boto/s3/key.py", line 653, in set_contents_from_file
self.send_file(fp, headers, cb, num_cb, query_args)
File "/usr/lib/python2.7/dist-packages/boto/s3/key.py", line 535, in send_file
query_args=query_args)
File "/usr/lib/python2.7/dist-packages/boto/s3/connection.py", line 423, in make_request
override_num_retries=override_num_retries)
File "/usr/lib/python2.7/dist-packages/boto/connection.py", line 618, in make_request
return self._mexe(http_request, sender, override_num_retries)
File "/usr/lib/python2.7/dist-packages/boto/connection.py", line 584, in _mexe
raise e
socket.error: [Errno 32] Broken pipe
I suspect it is dying when trying to find the mimetype and MD5 hash of /dev/xvda. So, I installed a newer version of Boto which has a set_contents_from_stream method to skip this:
Code:
root@hvc0:~# apt-get install python-pip
root@hvc0:~# pip install boto --upgrade
...
root@hvc0:~# python
>>> import boto
>>> conn = boto.connect_s3('<aws access key>', '<aws secret key>')
>>> bucket = conn.create_bucket('awesome-bucket-of-science')
>>> from boto.s3.key import Key
>>> k = Key(bucket)
>>> k.key = 'disk.img'
>>> fp = open('/dev/xvda', 'rb')
>>> k.set_contents_from_stream(fp)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/boto/s3/key.py", line 757, in set_contents_from_stream
% provider.get_provider_name())
boto.exception.BotoClientError: BotoClientError: s3 does not support chunked transfer
So, nope. I think it can certainly be made to work, but I've spent an hour on this and couldn't get it to upload my /dev/xvda, so it's your turn to play around with it for awhile! -rt
_________________
Code:
/* TODO: need to add signature to posts */