shell script to back up database and script folders
#!/bin/bash cd /ct20/uploads/backup/ NOW=$(date +”%m-%d-%Y”) tar -cjf backupsite_$NOW.bz2 /opt/www/ct20 tar -cjf backupcms_$NOW.bz2 /opt/www/cms tar -cjf mysqlbackup_$NOW.bz2 /opt/lib/mysql
#!/bin/bash cd /ct20/uploads/backup/ NOW=$(date +”%m-%d-%Y”) tar -cjf backupsite_$NOW.bz2 /opt/www/ct20 tar -cjf backupcms_$NOW.bz2 /opt/www/cms tar -cjf mysqlbackup_$NOW.bz2 /opt/lib/mysql
DB_LIST=”$(mysql -u root -Bse ’show databases’ | egrep -v ‘information_schema|mysql|test’)” for db in ${DB_LIST[@]} do TABLENAMES=”$(mysql -u root $db -Bse ’show tables’)” echo “Database: “$db for TABLENAME in ${TABLENAMES[@]} do mysql -u root $db -Bse “optimize TABLE $TABLENAME;” echo $TABLENAME” table has been optimized” done echo $db – $TABLENAME “Optimized has been completed” done echo “All Databases have been successfully Optimized”
DB_LIST=”$(mysql -u root -Bse ’show databases’ | egrep -v ‘information_schema|mysql|test’)” for db in ${DB_LIST[@]} do TABLENAMES=”$(mysql -u root $db -Bse ’show tables’)” echo “Database: “$db for TABLENAME in ${TABLENAMES[@]} do mysql -u root $db -Bse “Analyze TABLE $TABLENAME;” echo $TABLENAME “Analyze has been done” done echo $db – $TABLENAME “Analyzis has been completed” done echo “All Databases have been successfully Optimized”
$aDir = glob(”/clt20/uploads/videos/*.flv”); The glob() function searches for all the pathnames matching pattern according to the rules used by the libc glob() function, which is similar to the rules used by common shells.
cd /var/log/httpd NOW=$(date +”%m-%d-%Y”) mv mobile-error_log mobile-error_log-$NOW mv mobile-access_log mobile-access_log-$NOW /etc/init.d/httpd graceful sleep 5 tar -cvjf /opt/logbackup/logs-$NOW.bz2 mobile-error_log-$NOW mobile-access_log-$NOW scp mobile-access_log-$NOW domU-12-31-39-07-75-63:/clt20/uploads/mobilelog/ rm -f mobile-error_log-$NOW mobile-access_log-$NOW Remember we have exchanged the authentication key between the two servers.
Following command is used for remote syncing of a folder on two remote servers: /usr/local/bin/rsync -avz -e ssh /opt/www/cms/imagedata/2009/oct/ webdoc@domU-12-31-39-03-09-20:/opt/www/clt20/imagedata/2009/oct/ To rsync a particular file use: /usr/local/bin/rsync -avz -e ssh /opt/www/clt20/rss.xml webdoc@domU-12-31-39-03-09-20:/opt/www/clt20/
Here is the crontab code: # start apache on reboot @reboot mount -t ext3 /dev/sdf /opt/ @reboot /etc/init.d/httpd start # start mysqld on reboot @reboot /etc/init.d/mysqld start */10 * * * * /usr/bin/php /opt/www/cron/getlivestat.php 10 * * * * /usr/bin/php /opt/www/cron/generaterss.php 25 14 * * * /opt/www/cron/rotatelogs.sh */02 * * * * sh /opt/www/cron/imagedata_upload.sh >> /opt/www/cron/imagedataoutput.log To set crontab for a particular [...]
Finally rediff.com’s minimalist paying them. It pushed them from No. 5 india rankings to No. 8 .
Developing http://www.clt20.com/ was a great challenge. With the amount of time that we had, it was thought to be almost impossible. But great team work and 24 hour work schedules finally we made it. The end product is seen by you all. With 1 lakh unique visitors and 4 lakh plus page views everyday, i think we made it.
%s/\/images\//http:\/\/images.satishgaudo.com\/images\//g %s/\/js\//http:\/\/images.satishgaudo.com\/js\//g %s/\/css\//http:\/\/images.satishgaudo.com\/css\//g