Welcome to my blog!

Here I try to keep useful information about IT, mostly related to Web development and Linux stuff. Any comments or feedback that you might have will be much appreciated!

Thanks,
Tomi

Quick DB dumps with automatic file name generation based on date/time

Filed Under (Databases, Linux) by admin on 27-12-2009

Simple DB backup
mysqldump -h [server name] -u [user name] [db name] -p > site-db-`date +%y%m%d-%H%M`.sql

Complete MySQL dump with compression
mysqldump –all-databases -u admin -p`cat /etc/psa/.psa.shadow` > `hostname -s`-mysql-`date +%y%m%d`.sql
tar zcf `hostname -s`-mysql-`date +%y%m%d`.tgz `hostname -s`-mysql-`date +%y%m%d`.sql
rm `hostname -s`-mysql-`date +%y%m%d`.sql

Complete HTTP sites data with compression
cd /var/www/vhosts/
tar zcf `hostname -s`-sites-`date +%y%m%d`.tgz * –exclude=*/statistics/* -v –exclude=ilatina.com/httpdocs/downloads/
mv `hostname -s`-sites-`date +%y%m%d`.tgz /root/.data/`hostname -s`

Quick MySQL random passwords

Filed Under (Databases) by admin on 02-09-2009

If you need to quickly generate passwords within MySQL, you could try one of the following methods:

  1. SELECT CONV(FLOOR(RAND() * 99999999999999), 10, 3);
  2. SELECT SUBSTR(MD5(RAND() * 99999999999999), 1, 10);  

Showing MySQL and PostgreSQL’s results on expanded or vertical display

Filed Under (Databases) by admin on 16-09-2006

I do a lot of development with PHP, and often I need to work directly with PostgreSQL and MySQL’s client consoles, for schema work or data manipulation.

On both database clients, you can see a result set on expanded or vertical display (the output formatted in rows instead of the usual columns) with the following methods: Read the rest of this entry »