UnixServerAdmin

Server Administration & Management

Rsync Tips

Synchronizing data beetween two directories

# rsync -rv <src> <dst> –progress

Rsync two directories with filtered extensions

# rsync -rv –include ‘*/’ –include ‘*.txt’ –exclude ‘*’ srcDir/ desDir/

Rsync a directory excluding pesky .svn dirs

# rsync -rv –exclude .svn src/dir/ dest/dir/

Sync Source Directory to Destination Directory

# rsync -avzE -e  –process /var/www/html/deploy root@X.X.X.X/backup/testing/project

# rsync -avzE  /var/www/html/deploy root@X.X.X.X://backup/testing/project/

src :- source
dst :- destination
-v :- increase Verbosity
-a :- archive mode
-r :- recurse into directories
-e :- Specify remote shell to use
-r :- for recursive (if you want to copy entire directories)
–process :- to show a progress bar)

 

January 15, 2012 Posted by | Tips & Tricks, Unix/Linux | , , | Leave a comment

cPanel: rsync error

If you have issued the following command

# rsync -av rsync://rsync.cpanel.net/scripts /scripts;chown 0.0 /scripts

And resulting in the  following error message:

rsync: failed to connect to rsync.cpanel.net: Connection refused (111)
rsync error: error in socket IO (code 10) at clientserver.c(94)

Here is the fix

cPanel has discontinued the use of rsync and all syncs need to be done using using the following command. Run these commands as root:

# /scripts/cpanelsync httpupdate.cpanel.net /cpanelsync/RELEASE/scripts /scripts

December 19, 2011 Posted by | cPanel | , | Leave a comment

Backup_rsync.sh

###########################################################
## backup_rsync.sh ##
###########################################################
## Make a Directory /REPORTS ##
## Make a file msg.txt under /REPORTS Directory ##
## Write Following in msg.txt file ##
###########################################################
## Hi, ##
## The Incremental Backup Report of server is attached with this mail. ##
## Thanks & Regards, ##
## Unixserveradmin.com Security Team ##
###########################################################
#! /bin/bash

/bin/echo “=================================================” > /REPORTS/Backup.log_$(date +%d%m%y)
/bin/echo “THE BACKUP IS STARTED AT $(date)” >> /REPORTS/Backup.log_$(date +%d%m%y)
/bin/echo “=================================================” >> /REPORTS/Backup.log_$(date +%d%m%y)
/bin/echo ”      ” >> /REPORTS/Backup.log_$(date +%d%m%y)
/bin/echo ”      ” >> /REPORTS/Backup.log_$(date +%d%m%y)
/bin/echo “=================================================” >> /REPORTS/Backup.log_$(date +%d%m%y)
/bin/echo “BACKUP LOGS ARE AS FOLLOWS:”  >> /REPORTS/Backup.log_$(date +%d%m%y)
/bin/echo “——————————————————–”  >> /REPORTS/Backup.log_$(date +%d%m%y)
########### Remote Sync between two directory ###########
#/usr/bin/rsync -avzE  /var/www/html/example/ root@X.X.X.X:/var/www/html/example/ >> /REPORTS/Backup.log_$(date +%d%m%y)
########### Remote Sync between two directory except config.php file ############
#/usr/bin/rsync -avzE –exclude config.php  /var/www/html/example/ root@X.X.X.X:/var/www/html/example/ >> /REPORTS/Backup.log_$(date +%d%m%y)
########### Remote Sync Two directory except config.php and *.txt files ###########
/usr/bin/rsync -avzE –exclude config.php –exclude ‘*.txt’  /var/www/html/example/ root@X.X.X.X:/var/www/html/example/ >> /REPORTS/Backup.log_$(date +%d%m%y)
#####################  #####################
/bin/echo “——————————————————–” >> /REPORTS/Backup.log_$(date +%d%m%y)
/bin/echo “=================================================” >> /REPORTS/Backup.log_$(date +%d%m%y)
/bin/echo “THE BACKUP HAS BEEN COMPLETED AT $(date)” >> /REPORTS/Backup.log_$(date +%d%m%y)
/bin/echo “=================================================” >> /REPORTS/Backup.log_$(date +%d%m%y)

mutt -s “REMOTE BACKUP REPORT $(hostname | tr ‘a-z’ ‘A-Z’)” -a /REPORTS/Backup.log_$(date +%d%m%y) unixserv@unixserveradmin.com < /REPORTS/msg.txt

mutt -s “REMOTE BACKUP REPORT $(hostname | tr ‘a-z’ ‘A-Z’)” -a /REPORTS/Backup.log_$(date +%d%m%y) info@unixserveradmin.com < /REPORTS/msg.txt

December 6, 2011 Posted by | Shell Script, Tips & Tricks | , , | Leave a comment

backup_remote.sh

#############################################################
## backup_remote.sh ##
#############################################################
## Script for Data Backup Transfer on Remote Server by rsync ##
#############################################################
## Make a Directory /REPORTS ##
## Make a file msg.txt under /REPORTS Directory ##
## Write Following in msg.txt file ##
#############################################################
## Hi, ##
## The Backup Report of the  server is attached with this mail. ##
## Thanks & Regards, ##
## Unixserveradmin.com Security Team ##
#############################################################
## X.X.X.X –> Remote Server IP Address ##
## ssh -p 8765 –> SSH Port No. 8765 ##
#############################################################
#! /bin/bash

/bin/echo “========================================================” > /REPORTS/Backup.log_$(date +%d%m%y)
/bin/echo “THE BACKUP IS STARTED AT $(date)” >> /REPORTS/Backup.log_$(date +%d%m%y)
/bin/echo “========================================================” >> /REPORTS/Backup.log_$(date +%d%m%y)
/bin/echo ”      ” >> /REPORTS/Backup.log_$(date +%d%m%y)
/bin/echo ”      ” >> /REPORTS/Backup.log_$(date +%d%m%y)
/bin/echo “========================================================” >> /REPORTS/Backup.log_$(date +%d%m%y)
/bin/echo “BACKUP LOGS ARE AS FOLLOWS:”  >> /REPORTS/Backup.log_$(date +%d%m%y)
/bin/echo “——————————————————–”  >> /REPORTS/Backup.log_$(date +%d%m%y)
/usr/bin/rsync -avh -e “ssh -p 8765 –delete-after” /disk2/daily X.X.X.X:/disk3/ >> /REPORTS/Backup.log_$(date +%d%m%y)
/bin/echo “——————————————————–” >> /REPORTS/Backup.log_$(date +%d%m%y)
/bin/echo “========================================================” >> /REPORTS/Backup.log_$(date +%d%m%y)
/bin/echo “THE BACKUP HAS BEEN COMPLETED AT $(date)” >> /REPORTS/Backup.log_$(date +%d%m%y)
/bin/echo “========================================================” >> /REPORTS/Backup.log_$(date +%d%m%y)

mutt -s “REMOTE_BACKUP REPORT $(hostname | tr ‘a-z’ ‘A-Z’)” -a /REPORTS/Backup.log_$(date +%d%m%y) unixserv@unixserveradmin.com < /REPORTS/msg.txt

mutt -s “REMOTE_BACKUP REPORT $(hostname | tr ‘a-z’ ‘A-Z’)” -a /REPORTS/Backup.log_$(date +%d%m%y) info@unixserveradmin.com < /REPORTS/msg.txt

May 7, 2011 Posted by | Shell Script | , , | 5 Comments