Monday, December 21, 2009

Arrange Fields in Trac Tickets

I was struggling one day to organize fields in the order I want when I create tickets in Trac.

  1. Copy templates/ticket.html into trac/myproject/templates/ticket.html

  2. Insert the following code snippet to the beginning of the template:

  3. <?python
    # define the order
    field_types = ["type", "priority", "milestone", "keywords", "cc", "component"]

    # Sorting function
    def sort_nicely(field1, field2):
    idx1 = field_types.index(field1['name'])
    except ValueError:
    idx1 = 1000 # no match, push to the end

    idx2 = field_types.index(field2['name'])
    except ValueError:
    idx2 = 1000 # no match, push to the end

    return cmp(idx1, idx2)


That's it, if you have any custom fields and you want them ordered, put them into the field_types list.

Wednesday, November 11, 2009

Magento and Drupal Integration

There are numerous ways to integrate Magento with Drupal. Here I will share my experiences while working on that with very smart people at Optaros. I don't take credit for all the points in this post, because they are the product of the whole team.

The motivation for this kind of integration is the innovative look into where e-commerce is moving. To get a grasp of it look at OCentric. To keep it short, content is free advertisement for products. It allows customers to get more input about products and provides the meat for search engines to index.

Briefly, there are several main approaches to integrate Drupal and Magento:

  1. let Magento be the main component, while leaving Drupal just as a subcomponent

  2. let Drupal be the main component, and have Magento as an e-commerce  module

  3. let  both Magento and Drupal be main components

These are general approaches and each of them have different pros and cons. They will be further detailed by usecases, complexity, technicalities, etc. in the following sections.

Moreover, we will release much of the code as open source, so it's not only a theoretical discussion here:)

Magento as the Main Component

This is probably the most acceptable approach in terms of implementation complexity. Moreover you can choose different level of complexity to implement.

The straightforward solution is to integrate on the service layer. Meaning that whenever we are on the e-shop product page we have to call a Drupal service to bring related content, for instance blog posts. The same holds for category pages. How to do that:

  • Create a Drupal module that allows you assigning categories and products  to a content node in Drupal

  • Implement XML-RPC client on Magento side and use it to talk to services on Drupal in order to pull the content (e.g. using view.get or node.get funuctions)

  • Rewrite the category and product controllers on Magento to take the content from Drupal into account

There are some challenges in taking this way. They are mainly for those who want to implement features in a generic way. Specifically, whenever you add a CCK field or a feature like rating to a content type, you have some work to do on the Magento side. Namely, you need to modify layout and write templates to handle this additional data coming from Drupal. Hence it's pretty cumbersome to use Drupal community contributed modules as you need to do some coding on Magento side for every new Drupal feature. This is quite easy when the content from Drupal is read-only, but as soon as you want commenting, rating, flagging, etc. it becomes an issue, because you need to not only redo rendering on Magento but also map the functionality.

A more complex path to take  is to integrate the whole Drupal rendering engine into Magento, however, this means a very tightly coupled architecture... Still, if you plan to use many many many of the Drupal features it may make sense. This will require writing a Drupal module for Magento that will adapt every Drupal core function to Magento. Could end up as a very complicated solution.

We chose the XML-RPC because of the given time frame and specific requirements. Normally a product or a category will be associated with a very specific set of content types, and therefore the fully generic solution may not pay off.

By the way there is already a CMS module for Magento as part of the core. And the question is why would one want to struggle integrating Drupal instead of using that CMS module? Moreover, with enterprise 1.6 version of Magento the module offers quite cool features. Some things from the top of my head to consider:

  • Drupal has a solid community, and it is more stable and feature-rich than the Magento CMS module will ever be (of course it's good as soon as you make the Drupal-Magento integration reasonably flexible)

  • There is the CCK module that allows to very quickly add additional fields to a content type and make it available to the content producing team

  • Content versioning, workflow, etc. is easy in Drupal

  • ...more ?

Drupal as the Main Component

This approach has been already taken by others and you can start digging for it here. We've tried out the available modules but didn't stick with them... Basically there the implementation is based on the notion of synchronizing Magento products, categories, orders, etc.  into Drupal using a cron job.

In general, although Drupal-as-the-main-component approach in the end may give a lot of  flexibility, it may be too complex to implement. Imagine that the whole Magento frontend functionality needs to be rewritten for Drupal. Magento would then only be an e-commerce backend (the admin part) accessible via Web services. Of course you'd be able to use plenty of Drupal modules as well as flexible templating without any hassle, have better performance, and many other goodies but it just looks too expensive to implement.

Still, bringing only a part of Magento into Drupal makes a lot of sense (as in that module that synchronizes products and orders into Drupal using cron job). In this case it's a decision to make whether the site is more about content or about commerce. When it's about content, then you don't really care about SEO for products, fancy business logic, etc.

Both Mangento and Drupal as the main Components

This is reasonable when the content will be displayed on the Drupal site and e-shop on the Magento site. Meaning that no proxying for content happens behind the scenes. So if a product has a blog post attached, then on the product page you'll have a link (maybe even the post itself loaded using Ajax call) and clicking it will open a Drupal page with that blog post.

One of the challenges here is to maintain two different themes in order not to harm user experience. So that when the customer clicks on the blog link inside the product page the blog is displayed with the same look and feel as the shop. For that you can't avoid coding on two different frameworks. Apart from theming SEO will have to be also maintained on both components.

Another challenge would be the ability to mix content with product information on the same page. Some kind of communication on the service layer will be necessary for that, which means that it's not really reasonable to use this dual approach with such a usecase present.

It may make sense, however, to take this path when there are only some of the things to be shared between both components, e.g. users, and everything else is completely separate. For example, when a company has an e-commerce site, a customer community site, and a corporate site.

Additional Points for Integration

The end user display is only one part of the story. When you integrate this kind of monster systems to work seamlessly you get trapped with other things besides templating.

One of them is single sign on. A good thing to do here is to use CAS. Drupal already has the CAS module. Magento, however, needs one (we've been writing one). The good news that all the low level protocol implementation is available for PHP as open source.

Another thing is search. Independently of the integration approach chosen eventually you want to search for products and content in the same search box. This may become pretty challenging but it's not impossible. We've got a proof of concept for the store front in Magento, where we leverage Solr search. It performs really well for our suggest box functionality.

There are numerous ways to integrate Magento with Drupal. And here I will share my experiences while working on that with very smart people at Optaros. asdfa sfd

asdf adsfasdf asdfasdf

Sunday, November 8, 2009

Interactive Projection

I wonder if there is a technology that allows interaction with a projection. I was looking around the Web but all I could find was fancy and expensive (multi)touch screens.

I think it should be somehow possible to track hand movements from the outside only by means of a little camera and software; similar to the way eye tracking software works.

Imagine you put a little device that is watching how you are doing a presentation by projecting slides on a wall. As soon as you wipe the wall the next slide eases in; you zoom in/out with two hands the same way you achieve that with two fingers on iPhone; when you want to fast forward a movie you wipe with the faster movement; etc.

Probably the challenge would be not to stand in the way of the tracking device and, of course, to clean the wall you've been touching after lounch:)

Is HTC Hero for the left handed?

Recently I obtained an HTC Hero and I really like it. I've never had an iPhone but my friends say it's pretty much the same. I say that it's the same but better. I always prove that with the Google Sky app.

One drawback though is that the "back" button (used very often) is on the bottom right of the device panel. So when you hold it in your right hand it's physically very uncomfortable to click that button. I mean very.

Monday, October 26, 2009

Content Maganement with the Delegated Features as Services

As a friend of mine pointed out:  there used to be a server and many terminals, currently we have a bit more sophisticated terminals - PCs - and our big server is the Internet, where the apps are "on the cloud". Nice analogy, and for me it makes a lot of sense. Are we really coming back to the terminal-server age but in a more advanced, i.e. distributed version?

Anyway I think that every feature in a Web application should be a service. Not a service in a sense of a mashup or SOA, but in a bit different sense.

Let's take a simple example - Drupal. It's a content management system. The power of it is that it's extensible with new modules that are normally contributed by the community. These modules implement different features, such as rate the content, comment, spam filter. One of the nice ones that I really like is made by the Drupal inventor Dries Buytaert, called Mollom. In fact it's a gluing module for the Mollom service, the service does spam filtering for your site. Specifically, when a person presses the "Save" button, the post first travels to the Mollom service, and then is checked if it's spam, in case it looks suspicious the user has to fill in a CAPTCHA in order to save the post.

Now consider that all the modules in Drupal had the Mollom nature. That is the module would just be the glue for the service which lives somewhere on the cloud.

A simple content driven site based on Drupal could be quite easily implemented with what's available out there. Consider a site for video sharing, kind of YouTube but maybe not so generic. At the core is Node - the most primitive content type made of title and body. And now let's add features as services:

  • Comment the node - Disquss.

  • Control the spam - Mollom.

  • Let users send the feedback about your video sharing service - Zendesk.

  • Rate the content - Outbrain.

  • Share the content - AddThis.

  • Video upload and related features - Kaltura.

What else? Well there is one more piece that I think is very important:

  • Social graph management. There are many services available out there starting with Facebook and finishing with QQ. These services expose APIs so there are also gluing modules for Drupal available. There is one caveat with social graph management. What features one wants to map, is it only friending or also status updates, picture sharing, etc. The purest approach would probably be to have a gluing module in Drupal that only uses authentication and friending features of the social service.

All in all, I strongly believe that paying for a feature as a service is better than paying for (re)implementing and maintenance of that feature. So it's like SaaS but on a feature level, not the whole application (feature set).

Friday, October 9, 2009

Audiobooks Social Network

I like books.  Recently I got attracted by audiobooks. This looks like cheating a bit, because it's not pure reading, however, I must say it's far from cheating. Listening requires (at least for me) even more attention than reading.

Anyway, I am now keen on audiobooks, and as it usually happens, my experience with the Web comes into play. So I started thinking whether it is a valid idea to build a social site fully dedicated to audiobooks - or more generally reading text aloud and listening to recordings.

Let me analyze the idea of this social site in several axes.

Social object

Clearly the social object would be a piece of read aloud material. For simplicity we can think of a chapter of a book. When all the chapters are available the whole audiobook is there. Interestingly, an audiobook can be assembled into one even if each chapter is read by different people.

Social activities

We've got chapters of audiobooks as downloadable files on the site. There will be two kinds of people visiting the site: those who submit their readings to the site and those who will want to download audiobooks. Besides all the usual features like sharing, bookmarking, chatting, reviewing, flagging, rating etc. audiobookers will need some special tools and features, such as: audioconferencing for real time multicharacter recordings, a friendly avatar that impersonates the reader, rankings of the best (popular) readers, transcription of audio into text for search engine optimization, and so on.


Software-wise everything looks solvable. It's just a Web site maybe with AIR desktop applications for reading aloud, saving, organizing, listening, etc. to books. The greatest challenge is how to ensure that the reader is reading the book the way it was written. And then, how to ensure that the readers will correctly name the pieces they read so that they (semi-)automatically could become one audiobook. Probably this is only achievable by croudsourcing and social filtering.

Business case

All the materials on the site should be available for free because it's community generated content. Still there are plenty of opportunities for paid services. For instance:

  • assemble audiobooks out of separate chapters for those who don't have time to do that by themselves;

  • sell professionally read audiobooks; allow the readers selling their recordings and take a percentage from each transaction;

  • provide additional tools for readers to promote themselves and get statistics;

  • organize paid events where book authors read aloud a chapter or two of their books;

  • use the audiobooking infrastructure for voice recordings management system as a service;

  • etc.

Monday, August 17, 2009

Tidy Up My Friend Feed

There is one feature missing on Facebook (I believe in many other social networks as well) - digest view on friend's activity. Of course I can go to my friend's profile and see all the activity, but there should be something more user friendly.

Consider the following scenario:
I am on my Home page on Facebook. Here I see all the (non hidden) friend activity. E.g. somebody posted a picture, somebody shared a link, somebody liked a song. Apparently there are some people which are very active, so they do those activities very often during the day. Alternatively there are more passive friends doing those activities very rarely, e.g. once a week

In this scenario there are two things to notice:

  1. Active friends will take up a lot of space on your Home page (or life feed in general).

  2. Passive friends will be quite invisible in all the sea of posts.

It's very likely that an activity done by a passive friend is more valuable than 10 posts from a very active (and maybe not the best) friend. So what we normally do? We hide the posts of very active friends. Otherwise we put those active people to another list. All in all we want to clean up the main life feed on the Home page.

What we actually do is spam filtering on our friend's posts. That's not good, because we know that they are friends and the stuff they do is not spam (even if sometimes it does not concern you).

I think the solution to that could be a digest view on friend's activity. Mailing lists work this way. There I can specify, that I want to receive one e-mail per day with all the discussion topics listed. Following this approach would allow grouping all the posts of my active friends opposed to having them flat-listed by time.

Thursday, July 30, 2009

A Browser That Removes Ads

A couple of days ago my friend was very annoyed by an advertisement which produced some sounds when you mouseover it. And the ad was placed in such a way that he would go on it quite often.

I wonder if there is a Firefox add-on which simply removes the ads from a page. It would solve not only the problem that my friend had, but also a more generic one. Imagine it would be possible to browse ad-free, that should be really awsome.

The ad removal plug-in could be trained by users to detect ads, e.g. served by Google:). All the information about where the ads or banners are could be stored in some public database, and the plug-in could leverage the collective knowledge of all Web users. Considering that ads are normally served as:

  • external javascript

  • iframe

  • inline images or text

it should be rather easy for a browser to simply remove some pieces of HTML from the DOM or put them somewhere at the bottom of the page so that they don't disturb the eye.

Wednesday, July 29, 2009

Making Money with OAuth

I am really excited about the idea implemented by RPXnow. It works as simple as:
... a proxy between third party identity providers and your website, RPXnow helps you effortlessly add single sign-on from providers like AOL, Google, Yahoo! and even Facebook. The hosted service runs in the cloud and is accessed via simple RESTful API calls ...

A set of features looks impressive, let me list them here (or see them with descriptions):

  • Supported identity providers: Google, Yahoo, Facebook, Twitter, MySpaceID, Windows LiveID, AOL, Blogger, Wordpress, VeriSign, Hyves, OpenID

  • Sign in widget

  • Profile data from the identity providers

  • Account mapping

  • Extended access to the providers' APIs

  • Social publishing (coming soon)

  • Address book import

I want to note that RPXnow is positioning themselves as a "Single Sign-On for your website" although it provides with much more. And this much more, I think, could be a totally separate business.

RPXnow is putting effort to become a service that aggregates people data accross many services (e.g. MySpace and Facebook). Think of it as, but without the UI, just the REST API. Normally, if in your website you'd want to access user's MySpace, Facebook, or Google account data, you'd have to code everything yourself using the APIs provided by those services. RPXnow does it for you. So you only need to interact with one API - RPXnow API.

Recently I was reading the article Writing OAuth Gadgets, and then stumbled upon a concept of OAuth Proxy. As you can imagine it's a proxy design pattern applied for OAuth services, i.e. you provide an OAuth service that delegates to another OAuth service. Actually, the upcoming "Social publishing" feature of RPXnow will do exactly that - proxy to other services.

I think OAuth proxy could be a totally separate service in the cloud. There are many services online that allow for pretty much similar things: status updates, picture uploads, videos, profile information, etc. So the proxy could unify all this kind features into one interface and adapt to multiple services. As a customer of the proxy I would simply ask to upload a picture on behalf of a user, and I don't care where it goes - MySpace, Facebook or Flickr.

The question then if OAuth proxy as a business is possible without the "Single Sign-On for your website" like RPXnow. Because if not, then OAuth proxy would have to compete with RPXnow. I think it's possible. Consider a couple of use cases:

  1. A website that already has a lot of users. Instead of changing there authentication strategy it may be more feasible to implement the "Link external account" functionality and use OAuth proxy

  2. OpenSocial containers could use the more generic OAuth proxy than proxying just as a workaround

Maybe there are more?

Additionally, since OAuth proxy is actually software as service (SaaS) it implies recurrent revenue.

Friday, July 3, 2009

Remove an Account

How I hate when I sign up for some service and then I can't remove myself from it. Of course for service providers it's fine, just several records in the DB, but for me... I loose control of my data.

What made me write this post is Audible. I thought, I'd buy an audiobook, and this service seems to be well known around the world. So I added my book to the shopping cart, and was required to sign up in order to proceed. Which I did, but then I was notified that I can't place an order because I am not in the right geography (I live in Switzerland).

Hell, I thought, and went to Amazon, but the audiobook store there actually brings you to Audible for downloads... And there I got the same message.

Ok, then it doesn't make sense for me to be on Audible, if I live in the wrong place:) However, I can't find the way to remove my account. All the credit card details are there, and I can't delete at least those... This really sucks.

Friday, June 26, 2009

Why Do We Still Maintain Those User Accounts on Our Services?

Let's say you're building a website or an e-commerce site where you expect to have many visitors. By default you consider that people will need to log in to the site. When they log in, you'll collect some data about them. Sooner or later this data may be changed by the user on his/her profile page. This is a usual scenario, as old as web apps are.

And in every single project of that sort - the same thing: user registration, account management, password reminder etc. etc. If you look at a decent e-commerce software (e.g. Magento) or some content management system (e.g. Drupal) these features are built-in and looks like there is no issue with that. Surely, you can't have anonymous people doing things with your service.  And of course user profile data is a very valuable piece of information.

But here is a paradox: by collecting this valuable user information we actually lose much other valuable (or even more valuable) information and when we realize that we need it (e.g. user social graph) we start building on top of what we have, in order to obtain it... Complicated life...

If we look around every single web site has a database of users. And this database is filled by almost always the same process:

  • Register

  • Confirm your e-mail

  • Fill data in your profile

What about only one and a half step:

  • Register

  • (modify information about yourself)

I strongly believe that the second case can be achieved using OpenID and OAuth and some code around them.

A big part of the account management feature in web applications can (and probably should) be delegated to third party services such as different social networks. This is because the e-mail is not a personal identifier anymore (just look at Google Wave - email is not there at all). If I play in a band I will most likely share my MySpace url; if I am a hardcore blogger, I'll give everyone the link to my blog; if I am networking on Facebook, I'll simply connect to people by their name. E-mail is good only to confirm one's identity, not to represent it.

A shift in thinking of web apps is necessary to go from 3-step account management to 1.5-step. How to do that?

  1. Instead of registering user using their e-mail force them to sign up using their confirmed identity on another (trusted) service. For instance, if I'am creating a website or e-shop the default way for users to log in should be with Facebook or Google.

  2. Prefil user profile with data from the external service as follows:

    • Pull user picture (allow to swap it with his/her Gravatar) and other relevant info

    • Let the user to connect other services to your application, e.g. Flickr, Facebook, or whatever makes sense.

    • Ask for additional data that is not provided by third parties (preferably only when it's necessary to perform an action on the site)

    • Allow the userto create a persona and define privacy settings

That's it!

Look at Google Friend Connect. Ok, it's very general purpose, not even sure if it's a very successfull project. Still it depicts how websites should operate, i.e. people should navigate around the web and have their social life present everywhere. That's how we live in reality: we travel to different places but are always in touch with relatives and friends via phone, email, etc. So every site on the Internet should have kind of  "Friend Connect" feature instead of the stereotipical user management feature.

Of course, we can run into issues and questions like:

  • Identity mapping, when the user is allowed to sign in using different identities from different services

  • How expensive is it to build the user management infrastracture genuinly based on integration to other services as opposed to having standard (prebuilt) e-mail based implementations?

  • How much can one trust in the third party services? What if companies behind them go bankrupt?

But let me list the benefits from top of my head:

  • User is not required to sign up to yet another service, giving away the e-mail, memorizing the password

  • Since social networks will be like air, we're already integrating to other services through REST or JavaScript APIs. So why not doing it from the scratch?

  • Thanks to OpenID and OAuth as soon as another service appears it's relatively easy to plug it into your site if you've pluged one already

  • You get much more data about users on your site(e.g. friends, activities etc.), so you can track and engage in many different ways than just e-mail

  • The user experience of 1.5-step scenario is better than that one of 3 steps

  • Using computing resources of third party services

  • You might be able to bring your service to outside just your website, e.g. an OpenSocial widget on MySpace. This may turn into a viral effect which could increase the popularity of your service.

In short, let the people be free, don't close them in your little "walled garden", it just does not make sense, as you'll have to break the walls anyway :)

Wednesday, June 24, 2009

Relevant Search on the Web with a Personal Crawler

I thought (and I strongly believe that somebody already thought about the same before me :D) that it would be great to have a search that's relevant only to you. With Google you can kind of personalize your searching experience, but I mean another thing.

Let's say:

  • I've got hundreds of followers on Twitter and I follow a hundred people

  • I'm on Facebook where I've got many friends

  • I'm using Delicious for bookmarks

  • I use Google Reader for keeping myself up to date

  • I blog myself, and I receive comments on my posts

  • etc.

In all the listed services/activities there is a substantial set of links present or produced either by me or by people in my network. These links form a slice of Internet that is relevant to me.

Intuitively, the part of Internet that is relevant to me is growing:

  1. as I'm expanding my social graph

  2. as I'm sharing links with others

  3. as I'm actively participating on the Web, e.g. commenting

however, a big part of my subInternet is actually hidden (not public), e.g. links shared by friends on Facebook.

Now, imagine that you have your personal Web crawler (maybe plugged into Google). This way you could search in 3 modes:

  1. The Web - as we are used today

  2. The relevant part of the Web only - available via OAuth, Facebook Connect, etc.

  3. Both

As an example consider the keyword "birthday" in all the three cases. It's pretty clear that the results will be quite different.

Friday, May 29, 2009

Platform as a Service (PaaS) or Cloudware

PaaS, as Wikipedia puts it, is a bit clumsy to understand. You can get an expensive definition with examples from Forrester, if you will :) There is also the which seems to be (or to become) the central place for PaaS related resources. Also Google Search gives some useful links to read about PaaS, worth checking at least the first ten of them.

Why am I writing about PaaS? Because I got excited by the term, which I never heard or thought about.

Before not long ago I new SaaS, which currently is quite a comon business model - simply put up some software on your infrastructure and charge the users for using it. The best example in this area for me still is CRM provided by At Optaros we call this model Rent. You can read about Assemble vs. Build, Buy, Rent in the company's blog, pretty simple and quite interesting.

So SaaS is an genious idea. It allows for recurrent income, which is always good in hard and unpredictable times (provided that the customers are already there). Optaros realized that Assemble goes very well with SaaS in the way that we call Hybrid offering. To keep it simple the hybrid offering is: build the app and rent it (most likely to the same customer). Doesn't it sound more like a nice theory which is practically difficult to implement? Well, it is difficult but not impossible. Just check out what the Assembled Web is and then combine it with OView. Shortly, customers get a bunch of assembled apps floating around the Web and delivering their branded presence outside their main Web site. Moreover the customers get full control and overview over theoe apps. So this hybrid offering is really a simplified PaaS.

Having said that, looks like PaaS is actually a natural successor of SaaS. Intuitively it's something more than SaaS. What constitutes "more" is the delta between what is Software and what is Platform. Hence in PaaS business model it's a more complex software that's being rented. The complexity varies. It can be a virtual machine(s) that you rent, e.g. Amazon Elastic Compute Cloud, Google Apps Engine, etc. or infrastructure to build apps there, e.g. Bungee Connect,, etc.

Interesting what goes next in the line of SaaS > PaaS > ???. Soon my laptop will contain no code, nor IDE... just a browser. And I will forget how JAVA looks like, what is PHP, what is scalability issues, etc. I will just program on REST APIs and buy resources from someone on the cloud. Sounds like fun.

Thursday, April 30, 2009

OpenID + OAuth: Transcending Social Networks

So we're tired of remembering all the log in details for each service we use on the Web. For instance, I'd like to log in everywhere with my Google Account because I use a bunch of services on Google. Others may be spending more time on MySpace and would prefer to log in everywhere with their MySpace account. OpenID allows for that.

Another thing, I want to log in to Facebook and see the pictures that my friends shared with me on MySpace. E.g. Plaxo is doing that in a very consistent way, by integrating many many services under one Plaxo's ambrella. That's maybe an exaggeration but with OAuth everyone can do this.

And so I am also doing that on my free time: playing with OpenID libraries and trying to integrate with other sites using OAuth.

The fact that social networks will be like air motivates me. And the fact that I will be able to login to Facebook with MySpace credentials hints that I am on the right track. Finally when I see services (with a business model behind it) based on OpenID (e.g. RPX), I am really feeling that the whole Web soon will change.

Saturday, January 31, 2009

Backing up Drupal Quickly

I must admit, updating a Drupal instance, even if it's one module is a bit scary. And a rule of thumb is: backup, backup and backup the backup. So I do it.

Below I post a script that I wrote for that purpose (my first script for Linux :D). The folder structure on my server is:

The Script

today=$(date +"%Y-%m-%d")

cd ~/
mkdir $backups/$today


echo -e "TODAY: $today\n"

# 1.
echo "---Backing up Drupal 6.x without uploaded files---"

tar --create --gzip --file=$backups/$today/drupal-$drupal_v-no-files.tgz --exclude='sites/default/files' \
--directory=public_html drupal-6.x

echo -e "DONE\n"

# 2.
echo "---Backing up Drupal 6.x uploaded files---"

tar --create --gzip --file=$backups/$today/files.tgz --directory=public_html/drupal-6.x/sites/default files

echo -e "DONE\n"

echo "---Dumping the database---"

/usr/local/mysql/bin/mysqldump -u YOU -p --default-character-set=utf8 --result-file=$backups/$today/dump.sql DB
tar --create --gzip --file=$backups/$today/dump.sql.tgz --directory=$backups/$today dump.sql

echo -e "DONE\n"

echo "---Copying the settings---"

cp public_html/drupal-6.x/sites/default/settings.php public_html/drupal-6.x/.htaccess $backups/$today

echo -e "DONE\n"

echo "FINISHED. Please move the backup files to a safe location"