web analytics

Monthly Archives July 2013

Script to backup svn repo and copy to backup server

A small script which will be helpful for developers, it will take the svn backup on a daily basis. Now you can simple restore this backup to start working with it in another server.

#!/bin/sh

TO=”abc@xyz.com”
CC=”def@xyz.com”
SUBJECT=” SVN backup done”
SUCCESS_MSG=”SVN dump has been copied successfully”
ERROR_MSG=”SVN dump error”
ERROR_SUBJECT=”URGENT – SVN dump error”
svn_output_file=/root/scripts/svn_error
rsync_output_file=/root/scripts/rsync_svn_error

### Suppose name of the repository is myrepo which resides at /var/www/svn/myrepo###
cd /var/www/svn
svnadmin dump myrepo > myrepo.dump  2>$svn_output_file
if  [ $? -eq 0 ]
then
rsync -avzrp myrepo.dump user@xxx.xxx.xxx.xxx:/data/rsync_backups/svn_dump/  1>$rsync_output_file
if [ $? -eq 0 ]
then
cat $svn_output_file | /bin/mail -s “$S...

Read More

SVN dump and restore

Backup of SVN repo can be taken as follows. Suppose repo name is divz,

svnadmin dump reponame > reponame.repo

 

This dump can be used to restore the repo as follows.

svnadmin load reponame < reponame.repo

Read More

Script to take mysql backup in plesk server and rsync to backup server

The following script will take the backup of all mysql databases and copy them to your backup server. This is a plesk server.

#!/bin/sh

TO=”abc@xyz.com”
CC=”def@xyz.com”
SUBJECT=”MySql backup – $HOSTNAME”
SUCCESS_MSG=” Mysql Backup Done”
ERROR_MSG=”URGENT – Mysql backup error ”
error_file=/root/scripts/mysql_error_file
rsync_progress=/root/scripts/rsync_mysql_progress

## Find files which are older than 2 days and delete them ###
find  /home/rsync_backups/mysql_backup/ -type f -mtime +2 -exec rm {} ;

mysql_user=admin
mysql_pass=`cat /etc/psa/.psa.shadow`
cd /home/rsync_backups/mysql_backup/

mysql_databases=`echo “show databases;” |mysql –user=$mysql_user –password=$mysql_pass | grep -v ^Database$`

for i in $mysql_databases
do
mysqldump –user=$mysql_user –password=$mysql_pass $i > $i...

Read More

Script to monitor software raid array

#!/bin/sh

TO=”abc@xyz.com”

CONTENT=`/sbin/mdadm –detail /dev/md3 ; /sbin/mdadm –detail /dev/md1`

COMPARE_md3=`/sbin/mdadm –detail /dev/md3 | grep “State :” | awk -F’:’ ‘{ print $2 }’`
COMPARE_md1=`/sbin/mdadm –detail /dev/md1 | grep “State :” | awk -F’:’ ‘{ print $2 }’`

if [ $COMPARE_md3 == “clean” ] || [ $COMPARE_md3 == “active” ] || [ $COMPARE_md3 == “clean, checking” ] || [ $COMPARE_md3 == “active, checking” ] && [ $COMPARE_md1 == “clean” ] || [ $COMPARE_md1 == “active” ] || [ $COMPARE_md1 == “clean, checking” ] || [ $COMPARE_md1 == “active, checking” ]
then
SUBJECT=”RAID Check OK – $HOSTNAME ”
echo  “$CONTENT”| /bin/mail -s “$SUBJECT” “$TO”
else
SUBJECT=”URGENT – Suspected failed drive in $HOSTNAME”
echo “$CONTENT” | /bin/mail -s “$SUBJECT” “$TO”
fi

Read More

Enable root login in vsftp

Want to enable root access in vsftp? Do the following.

[~]# cp -pv /etc/vsftpd/ftpusers  /etc/vsftpd/ftpusers.bak.$(date +%F)

[~]# vi  /etc/vsftpd/ftpusers

Now remove root if present from the file. Save and quit the file.

We need to do the same from one more file also.

[~]#cp -pv   /etc/vsftpd/user_list  /etc/vsftpd/user_list.bak.$(date +%F)

[~]# vi /etc/vsftpd/user_list

Remove root from the users listed in this file. Save and quit.

Now restart vsftp.

[~]#/etc/rc.d/init.d/vsftpd restart

Now try connecting with root user in FTP.

 

Read More