I'm using ubuntu, and I accidentally deleted my project last weak. I tried to recover it but no luck.
Which is the best way to backup my project automatically including my Database (my database is Mysql)? What do you recommend?
First of all, let me just state the obvious: the solution that I'm about to propose is not going to bring your files back; it is a measure that you'll have to take from now on in order to prevent similar disasters in the future.
Basically, since you are working in your local machine (if you were working in the cloud you could automate a snapshot-taking process) you will have to keep a backup of 2 different things: the files and the database. Assuming that you are following the "drupal best practices code" and you are keeping every new file in the sites folder of your drupal installation, all you have to do is keep a regular backup of this folder and the database. So:
1) Regarding the "sites" folder: you can create a simple cron job that will compress and archive the folder regularly (even though it is out of the scope of this answer, you can find more information on crontab here)
2) Regarding the database: the solution here is actually pretty simple: "Backup and Migrate" module. It gives you the option to schedule your database backup and save the file through FTP in a remote server, send it through email or save it in your local machine. It's basically more than you'll ever need for this purpose.
P.S: I'm pretty sure that you will get some answers that you should be running a version control system to avoid things like that in the future. It's true that a version control system would be the ideal way to make sure that your files will not be lost in the future (the database is another story). However, the solution that I mentioned above is considerably faster and can get you up and running in no time. If you have time though, I would strongly suggest that you take a look at SVN or GIT (or any subversion control system that you like for that matter).
P.P.S: If the data that you lost is important, you can do a google search for data recovery software. A very quick search that I did gave me this.
Another option is to use "rsync" in Ubuntu, you can set it to perform regular cron jobs. I use this with the "luckybackup" graphical front-end and it is fast. Both are available from the ubuntu repositories and are quite easy to set up. I find it very effective, and I suppose its one of the many options available, but I find it very fast at backing up remote VPS installations, including the MSQL databases folder found on Ubuntu at /var/lib/mysql.
You should use a source control system for your code, github offers free hosting for public projects, or you can create a sandbox project on drupal.org.
Your database is a little more tricky, use mysqldump to export the database, and back it up via something like drop box. You can put the database into source control as well if you like, but it isn't ideally suited to that.
Take a look at the drush commands. drush helps you dumping your database with extra features (e.g. gzipping, import/export via rsync, filtering tables and more...). Take a look at the following commands:
It also makes syncing the filesystem easy. For this check out the core-rsync command. In combination these features can be very handy. Make sure to check out the other drush commands as well.