Categories

Backup files to S3 using Python Boto

If you want to copy local files from your Linux box to AWS S3, there are many ways to achieve that.

Here is one Python script which is using Boto, a interface between Python and AWS S3.

from boto.s3.connection import S3Connection
from boto.s3.key import Key
import boto

#create connection
conn = S3Connection(aws_access_key_id=’YOUR_ACCESS_KEY’,aws_secret_access_key=’YOUR_SECRET_ACCESS_KEY’)

#create S3 bucket
b = conn.create_bucket(‘new-bucket-name’)
k = Key(b)

#choose destination object name
dest = raw_input (“destination file name in s3?”)

dest2 = “%s” % dest
k.key = dest2

# put local file name you want to backup to S3
source = raw_input (“source file name which you want to backup?”)
source2 = “%s” % source
k.set_contents_from_filename(source2)

So basically, you can save this script in your $PATH as “s3-backup” and then just call it from your Linux shell.

Note: AWS S3 bucket names are acting as one big domain, so it is not possible to have the same bucket name someone already created. If you receive error because of this, create bucket with your own name

AWS fault-tolerant web app with GlusterFS

Building fault-tolerant and scalable web application is a MUST for every serious business and platform. Here you can find nice overview of techniques to achieve that in AWS.

But since AWS is a platform which allows you to build whatever-you-want on the top of it, some extra work is needed to achieve completely redundant and fault tolerant web app.

Here are instructions how to install GlusterFS on two instances which will be in replication mode, so in case one instance goes down, another will continue working.

Familiarize yourself with GlusterFS HERE

The web app will have the following components:

- Elastic Load balancer in 2 AZ

- In each AZ one web server instance

- in each AZ one glusterFS instance

- RDS database with replication

Continue reading AWS fault-tolerant web app with GlusterFS

NFS AWS howto

So… everyone are speaking about having single storage unit in AWS. That’s a real demand these days, and here is one way of doing that. The answer is – NFS!

So basically, you do the following:

- launch/create VPC

http://docs.aws.amazon.com/AmazonVPC/latest/GettingStartedGuide/ExercisePreqs.html

- create VPC private subnet

http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_Scenario2.html

- Launch instance in public subnet, and create NFS server:

yum install nfs-utils.x86_64 nfs-utils-lib-devel.x86_64 nfs4-acl-tools.x86_64 nfs-utils-lib.x86_64

- Create raid1 with “mdadm” tool as described here http://www.igord.net/2013/02/04/mdadm-raid-configuration/

- Mount your new mdadm raid volume to /mnt/data

- Put into /etc/exports the following (change IP addresses to suit your private IPs):

/mnt/data                       10.0.2.123(rw,sync,fsid=0,no_root_squash) 10.0.3.123(rw,sync,fsid=0,no_root_squash)

- On the client side:

yum install nfs-utils.x86_64 nfs-utils-lib.x86_64

- Put into NFS client /etc/fstab:

10.0.2.123:/ /mnt/data/ nfs4 soft,intr,rsize=8192,wsize=8192,nosuid

(adopt your private IP of NFS server)

$ mount -a

that’s it!

Hand of God

Look at this!

Amazing, I found it just in front of my apartment, attached to old church!

Best Linux movie player

Finally!

I found best Linux (Ubuntu) movie player EVER.

It’s called “smplayer” and is actually a web frontend for famous “mplayer” (command line player).

It has lot of nice features, some are:

- Search automatically for subtitles on opensubtitles.org
- Can play a ton of different video types without the need for additional codecs
- Remembers all your settings for every file you play—from playback position to subtitles to filters and equalizer settings

http://smplayer.sourceforge.net/en/downloads

Moja omiljena mesta u Beogradu / Favourite places in Belgrade

Hrana, kafane, kafići, klubovi

napomena: nemojte u Beogradu zaustavljati taxi na ulici ili ga uzimati sa lokacija gde ih ima mnogo tipa Autobuska/Železička stanica, Ušće, itd, jer ima mnogo divljaka! Uvek pozvati i naručiti Taxi telefonom!

Znak pitanja kafana Upitnik, ili “?”, je najstarija kafana u Beogradu i stranci obavezno dolaze ovamo. Ulica Kralja Petra je takođe jedna od najstarijih i uvek je lepo prošetati se njom.

Naše more kafana Kafana “Naše more” je kafana blizu autobuske stanice i idealno mesto ako ste gladni jer prave dobru klopu. Preporučujem škembiće i crevca na žaru!

Stepin vajat , kultni roštilj na Autokomandi, rade do 6 ujutru tako da je idealno mesto za posle grada ili u toku dana, jede se na otvorenom, ima stolice i stolovi i tende.

Kod Dače, malko skuplja kafana/restoran ali autentični stari enterijer i odlična klopa.

Skadarlija stara boemska ulica u Beogradu, sa mnoštvom restorana i kafana. Neki od meni omiljenih su Dva jelena, Ima dana, Dva bela goluba, pivnica Bip.

Kafana Korčagin Kafana u partizanskom stilu, sa raznim starim slikama i predmetima, uglavnom je za večernji noćni provod uz muziku, nisam siguran za hranu, uglavnom se pilo tamo.

Ćevabžinica “Cica” Autentični Sarajevski roštilj i sudžukice u centru, blizu Knez Mihajlove

Ada Safari na Adi Ciganliji Riblji restoran na otvorenom i zatvorenom, povoljne cene napolju, otići kad je lepo vreme jer je na otvorenom (ima i zatvoreni restoran ali nisam nikad bio)

Optimist Dobar pab za popiti pivo blizu centra.

Brod Još jedan dobar pab za popiti pivo blizu centra

KST Mesto za večernje izlaske sa metal muzikom, jeftinim pivom, studentima i mlađarijom

Plastik Disco / House muzika, cene malo više (tipa pivo je oko 250 dinara), ima da se naruče i kokteli tipa oko 1000 dinara i donese konobar par čašica za vas 5-6, mesto za đuskanje.

The Tube Mesto za izlazak uveče, house muzika, fensi mesto blizu centra.

Mesta koja treba obići

Kalemegdan, ogroman park sa divnim pogledom na Dunav, Savu i njihovo Ušće. U sklopu njega ima zoološki vrt, rimski bunar dubine više od 50 metara, utvrda, statua pobednika, vozić, crkva Svete Petke, Nebojšina kula u podnožju..

Dorćol Čitav ovaj kraj je jako zanimljiv za prošetati, svaka uličica krije nešto

Hram Svetog Save Lepo za videti i prošetati okolo po platou

Ada ciganlija Jezero i mnoštvo kafića oko jezera su idealni za opuštanje, šetnju po prirodi i provod

mdadm raid configuration

Few steps you need to perform, for example creating Raid1 and preserving it’s creation after server reboot:

# yum install mdadm

Now, first check your devices, for this example we will presume their names are /dev/xvdf and /dev/xvdg (modify this to suit your needs):

# mdadm –create –verbose /dev/md0 –level=1 –raid-devices=2 /dev/xvdf /dev/xvdg

Next, we want to find out if everything went OK:

Continue reading mdadm raid configuration

Sony Vaio Ubuntu touchpad issue – RESOLVED

I have installed Ubuntu 11 to my Sony Vaio laptop, but mouse touchpad was working very bad (i.e. was not working).

Solution:

First, check your Sony version, just to be sure:

# dmidecode -s system-product-name

After that, tell Ubuntu to use your touchpad as mouse PS2:

# echo options psmouse proto=imps | tee -a /etc/modprobe.d/psmouse.conf; modprobe -r psmouse; modprobe psmouse

Working right away!

Couldn’t untar /root/.cpan/ – RESOLVED

Recently I wanted to install some Perl modules for mail server vacation.pl script, but it was failing do to so:

# perl -MCPAN -e shell
# cpan> install DBD::mysql

Uncompressed /root/.cpan/sources/authors/id/C/CA/CAPTTOFU/DBD-mysql-4.022.tar.gz successfully
Using Tar:/bin/tar xvf /root/.cpan/sources/authors/id/C/CA/CAPTTOFU/DBD-mysql-4.022.tar:
Couldn’t untar /root/.cpan/sources/authors/id/C/CA/CAPTTOFU/DBD-mysql-4.022.tar

Hmm, but /bin/tar exists:

Coca Cola devil

image

Isn’t it obviously?