Web app backup simple shell script
- April 16th, 2010
- Write comment
Recently, the unofficial discussion board for students of my university department went down because of a misunderstanding with their hosting provider who also reassigned their machine to another customer wiping out all of their data. Now they restore the board but the last backup was dated back to last year so lots of data have been lost. Anyway, when one of the admins announced on facebook the board was up again, i ironically commented writing a small shell script that can be used to backup a simple mysql-based web application such as a discussion board or a CMS installation such as drupal, joomla, wp or whatever… But then i thought this happend more frequently than expected to people i know, so i decided to post that script here
#!/bin/bash #----------------------------------- # Web App. Dumb Backup Script # http://www.n0on3.net #----------------------------------- $user='your-username-here' $server='your-domain-name-here' $appname='your-webapp-name-here' $apppath='your-webapp-path-here' $mysqluser='your-mysql-user-here' $mysqlpassword='your-mysql-pwd-here' $dbname='your-mysql-db-name-here' #----------------------------------- d=`date +'%d-%m-%y'` ssh $user@$server "tar cjvf backup-$appname-$d-www.tar.bz2 $apppath" ssh $user@$server "mysqldump -u $mysqluser --password=$mysqlpassword $dbname > backup-$appname-$d-db.sql" scp $user@$server:$HOME/$user/backup-$appname-$d-www.tar.bz2 \ backup-$appname-$d-www.tar.bz2 scp $user@$server:$HOME/$user/backup-$appname-$d-db.sql \ backup-$appname-$d-db.sql ssh $user@$server 'rm backup-$appname-$d-*'
Please notice that here you are using ssh login without password, that means you have to append your client machine public rsa id to your server authorized keys file.
But more important, here you are writing your database password in plaintext because the script must use it, so if you keep such a script on your client machine remember to encrypt it or to take any proper precaution
In my
Sometimes you may just want to get the soundtrack of a video. And you know, today most videos are available in streaming on the web. There are several ways to download those videos, depending on the service that hosts them, but there are also many websites that explains how to do that. To give an example, youtube player retrieve videos requesting an URL with parameters that include the ID of the video and a signature it got when it’s loaded. To emulate this behaviour and get yourself the video to download, you can eg. use one of the appropriate
When you have to locally manage scrap metals, it doesn’t matter if you are connecting a microwave oven or a dozen of thousands bucks value brand new router or firewall, you will probably do that over a 

