LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-14-2011, 01:04 PM   #1
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
Rsync script help


Hello all its been a long time since I posted here, but I have a question about rsync. I have a script that I am trying to edit from jms1.net John Simpson if anyone knows him.

What I am after atm (end goal is a bit bigger will get to that on an other thread) is to only backup 1 directory and a set of files.

/usr/rx30 is the directory and i need all subdirectories too.
the list of files i need are as follows:

/etc/hosts
/etc/exports
/etc/dhcpd.conf
/etc/resolv.conf
/etc/cups/printers.conf
/etc/sysconfig/static-routes
/etc/sysconfig/network-scripts/ifcfg-eth0
/opt/ltsp/i386/etc/lts.conf
/etc/sysconfig/network-scripts/ifcfg-eth0:0

There will also become a time when I might need to grab additional directories off of /usr. Below is the script that I'm using with notes as to what I have modified. My issue is I'm getting an error due to my INCLUDES section.

Code:
# cat backup-servers 
#!/bin/sh
#
# backup-servers
# John Simpson <jms1@jms1.net> 2005-09-12
# Edited for TDS by Ray Brunkow <rbrunkow@rx30.com> 2011-11-14
# Documentation: http://www.jms1.net/docs/rsync-backup.shtml
#
###############################################################################
#
# Copyright (C) 2005,2006,2007,2008 John Simpson.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 or version 3 of the
# license, at your option.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################

PATH="/usr/bin:/bin"

##############################################################################
#
# configuration

BACKUPDIR="/backup"

LOGFILE="$BACKUPDIR/backup.log"			# in addition to syslog
SERVERS="10.10.4.77"				# servers to be backed up
KEY="/root/.ssh/id_dsa_backup"			# ssh key file

##############################################################################
# These can be uncommented out if you wish to perform a full system backup except these directories.
#
#EXCLUDES="/dev /proc /sys /tmp /var/tmp"
#EXCLUDES="$EXCLUDES /var/lib/pgsql/data /var/lib/mysql"
#EXCLUDES="$EXCLUDES /var/qmail/queue /var/qmail/simscan"

##############################################################################
#
# configured for TDS for INLCUDES for the rx30 directory and specific folders/files we need

INCLUDES="/etc/hosts /etc/exports /etc/dhcpd.conf /etc/resolv.conf /etc/cups/printers.conf /etc/sysconfig/static-routes /opt/ltsp/i386/etc/lts.conf /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0:0"
#INCLUDES="$INCLUDES "

# make sure cron's output gets mailed to the right place
MAILTO="postmaster@domain.xyz"
export MAILTO

##############################################################################

function log() {
	logger -t backup -p local5.info "$@"

	if [ -n "${LOGFILE:-}" ]
	then
		echo `date` "$@" >> $LOGFILE
	fi
}

##############################################################################
##############################################################################
##############################################################################

# make rsync use ssh with the correct key
RSYNC_RSH="/usr/bin/ssh -i $KEY"
export RSYNC_RSH

# make sure agent keys don't override the backup key
unset SSH_AUTH_SOCK

########################################
# if we were called with "-v", pass the "-v" along to rsync

if [ "$1" == "-v" ]
then
	OPTV="-v"
else
	OPTV=""
fi

########################################
# build list of excludes
# uncomment for the EXCLUDES
#EXC=""
#for e in $EXCLUDES
#do
#	EXC="$EXC --exclude=$e"
#done

#######################################
# build list of INCLUDES
EXC=""
for e in $INCLUDES
do
	EXC="$EXC --includes=$e"
done

########################################
# let's do it

log '/===================='
log "backup-server $OPTV starting"

for SERVER in $SERVERS
do
	########################################
	# make sure target directory exists

	TARGET="$BACKUPDIR/$SERVER"

	if [ ! -d $TARGET ]
	then
		mkdir -p -m 0755 $TARGET
	fi

	########################################
	# make sure an earlier backup isn't already running

	if egrep -q "^rsync.*${TARGET}" /proc/*/cmdline > /dev/null 2>&1
	then
		log "$SERVER already in progress"
		continue
	fi

	########################################
	# do the deed
	# uncomment the line with --bwlimit=1024 for WAN support.
	log "$SERVER starting"

        #rsync -aS $OPTV --delete $EXC --bwlimit=1024 $SERVER:/ ${TARGET}/
	########################################
	# use this line ONLY for LAN backups.

	rsync -aS $OPTV --delete $EXC $SERVER:/ ${TARGET}/
	rv=$?
	log "$SERVER done rv=$rv"

done

log "backup complete"
log '\===================='
This is the error im getting:

Code:
# bash -x ./backup-servers -v
+ PATH=/usr/bin:/bin
+ BACKUPDIR=/backup
+ LOGFILE=/backup/backup.log
+ SERVERS=10.10.4.77
+ KEY=/root/.ssh/id_dsa_backup
+ INCLUDES='/etc/hosts /etc/exports /etc/dhcpd.conf /etc/resolv.conf /etc/cups/printers.conf /etc/sysconfig/static-routes /opt/ltsp/i386/etc/lts.conf /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0:0'
+ MAILTO=postmaster@domain.xyz
+ export MAILTO
+ RSYNC_RSH='/usr/bin/ssh -i /root/.ssh/id_dsa_backup'
+ export RSYNC_RSH
+ unset SSH_AUTH_SOCK
+ '[' -v == -v ']'
+ OPTV=-v
+ EXC=
+ for e in '$INCLUDES'
+ EXC=' --includes=/etc/hosts'
+ for e in '$INCLUDES'
+ EXC=' --includes=/etc/hosts --includes=/etc/exports'
+ for e in '$INCLUDES'
+ EXC=' --includes=/etc/hosts --includes=/etc/exports --includes=/etc/dhcpd.conf'
+ for e in '$INCLUDES'
+ EXC=' --includes=/etc/hosts --includes=/etc/exports --includes=/etc/dhcpd.conf --includes=/etc/resolv.conf'
+ for e in '$INCLUDES'
+ EXC=' --includes=/etc/hosts --includes=/etc/exports --includes=/etc/dhcpd.conf --includes=/etc/resolv.conf --includes=/etc/cups/printers.conf'
+ for e in '$INCLUDES'
+ EXC=' --includes=/etc/hosts --includes=/etc/exports --includes=/etc/dhcpd.conf --includes=/etc/resolv.conf --includes=/etc/cups/printers.conf --includes=/etc/sysconfig/static-routes'
+ for e in '$INCLUDES'
+ EXC=' --includes=/etc/hosts --includes=/etc/exports --includes=/etc/dhcpd.conf --includes=/etc/resolv.conf --includes=/etc/cups/printers.conf --includes=/etc/sysconfig/static-routes --includes=/opt/ltsp/i386/etc/lts.conf'
+ for e in '$INCLUDES'
+ EXC=' --includes=/etc/hosts --includes=/etc/exports --includes=/etc/dhcpd.conf --includes=/etc/resolv.conf --includes=/etc/cups/printers.conf --includes=/etc/sysconfig/static-routes --includes=/opt/ltsp/i386/etc/lts.conf --includes=/etc/sysconfig/network-scripts/ifcfg-eth0'
+ for e in '$INCLUDES'
+ EXC=' --includes=/etc/hosts --includes=/etc/exports --includes=/etc/dhcpd.conf --includes=/etc/resolv.conf --includes=/etc/cups/printers.conf --includes=/etc/sysconfig/static-routes --includes=/opt/ltsp/i386/etc/lts.conf --includes=/etc/sysconfig/network-scripts/ifcfg-eth0 --includes=/etc/sysconfig/network-scripts/ifcfg-eth0:0'
+ log /====================
+ logger -t backup -p local5.info /====================
+ '[' -n /backup/backup.log ']'
++ date
+ echo Mon Nov 14 13:56:25 EST 2011 /====================
+ log 'backup-server -v starting'
+ logger -t backup -p local5.info 'backup-server -v starting'
+ '[' -n /backup/backup.log ']'
++ date
+ echo Mon Nov 14 13:56:25 EST 2011 'backup-server -v starting'
+ for SERVER in '$SERVERS'
+ TARGET=/backup/10.10.4.77
+ '[' '!' -d /backup/10.10.4.77 ']'
+ egrep -q '^rsync.*/backup/10.10.4.77' /proc/1/cmdline /proc/10/cmdline /proc/102/cmdline /proc/103/cmdline /proc/106/cmdline /proc/108/cmdline /proc/11/cmdline /proc/15/cmdline /proc/1576/cmdline /proc/16/cmdline /proc/17/cmdline /proc/176/cmdline /proc/177/cmdline /proc/178/cmdline /proc/179/cmdline /proc/180/cmdline /proc/181/cmdline /proc/1915/cmdline /proc/1916/cmdline /proc/1917/cmdline /proc/1947/cmdline /proc/1949/cmdline /proc/2/cmdline /proc/2182/cmdline /proc/2183/cmdline /proc/2388/cmdline /proc/2390/cmdline /proc/2412/cmdline /proc/2415/cmdline /proc/2436/cmdline /proc/2462/cmdline /proc/2463/cmdline /proc/2471/cmdline /proc/2490/cmdline /proc/2505/cmdline /proc/2514/cmdline /proc/2518/cmdline /proc/25225/cmdline /proc/25226/cmdline /proc/25251/cmdline /proc/25293/cmdline /proc/25296/cmdline /proc/25297/cmdline /proc/25304/cmdline /proc/2543/cmdline /proc/2579/cmdline /proc/2589/cmdline /proc/2602/cmdline /proc/2603/cmdline /proc/2611/cmdline /proc/2618/cmdline /proc/2626/cmdline /proc/2628/cmdline /proc/2630/cmdline /proc/2632/cmdline /proc/2634/cmdline /proc/2654/cmdline /proc/2679/cmdline /proc/2699/cmdline /proc/2708/cmdline /proc/2722/cmdline /proc/2734/cmdline /proc/2756/cmdline /proc/27675/cmdline /proc/27677/cmdline /proc/27681/cmdline /proc/27683/cmdline /proc/27685/cmdline /proc/27753/cmdline /proc/27756/cmdline /proc/27757/cmdline /proc/2776/cmdline /proc/2777/cmdline /proc/2778/cmdline /proc/2779/cmdline /proc/2780/cmdline /proc/2781/cmdline /proc/2782/cmdline /proc/2783/cmdline /proc/2784/cmdline /proc/2785/cmdline /proc/2788/cmdline /proc/27951/cmdline /proc/27952/cmdline /proc/2812/cmdline /proc/2821/cmdline /proc/2850/cmdline /proc/2859/cmdline /proc/28596/cmdline /proc/2862/cmdline /proc/2879/cmdline /proc/2910/cmdline /proc/2911/cmdline /proc/2912/cmdline /proc/2976/cmdline /proc/2988/cmdline /proc/2989/cmdline /proc/2990/cmdline /proc/2993/cmdline /proc/2995/cmdline /proc/2998/cmdline /proc/3/cmdline /proc/3000/cmdline /proc/3017/cmdline /proc/3019/cmdline /proc/3022/cmdline /proc/3044/cmdline /proc/3081/cmdline /proc/3097/cmdline /proc/3098/cmdline /proc/3148/cmdline /proc/3152/cmdline /proc/3160/cmdline /proc/3162/cmdline /proc/3163/cmdline /proc/3167/cmdline /proc/3172/cmdline /proc/3186/cmdline /proc/3188/cmdline /proc/3193/cmdline /proc/3194/cmdline /proc/3197/cmdline /proc/3200/cmdline /proc/3201/cmdline /proc/3424/cmdline /proc/343/cmdline /proc/381/cmdline /proc/382/cmdline /proc/3854/cmdline /proc/3855/cmdline /proc/386/cmdline /proc/387/cmdline /proc/3870/cmdline /proc/388/cmdline /proc/3912/cmdline /proc/392/cmdline /proc/393/cmdline /proc/394/cmdline /proc/395/cmdline /proc/396/cmdline /proc/397/cmdline /proc/4/cmdline /proc/401/cmdline /proc/402/cmdline /proc/410/cmdline /proc/423/cmdline /proc/446/cmdline /proc/481/cmdline /proc/5/cmdline /proc/6/cmdline /proc/6122/cmdline /proc/7/cmdline /proc/8/cmdline /proc/9/cmdline /proc/self/cmdline
+ log '10.10.4.77 starting'
+ logger -t backup -p local5.info '10.10.4.77 starting'
+ '[' -n /backup/backup.log ']'
++ date
+ echo Mon Nov 14 13:56:25 EST 2011 '10.10.4.77 starting'
+ rsync -aS -v --delete --includes=/etc/hosts --includes=/etc/exports --includes=/etc/dhcpd.conf --includes=/etc/resolv.conf --includes=/etc/cups/printers.conf --includes=/etc/sysconfig/static-routes --includes=/opt/ltsp/i386/etc/lts.conf --includes=/etc/sysconfig/network-scripts/ifcfg-eth0 --includes=/etc/sysconfig/network-scripts/ifcfg-eth0:0 10.10.4.77:/ /backup/10.10.4.77/
rsync: --includes=/etc/hosts: unknown option
rsync error: syntax or usage error (code 1) at main.c(1231) [client=2.6.8]
+ rv=1
+ log '10.10.4.77 done rv=1'
+ logger -t backup -p local5.info '10.10.4.77 done rv=1'
+ '[' -n /backup/backup.log ']'
++ date
+ echo Mon Nov 14 13:56:25 EST 2011 '10.10.4.77 done rv=1'
+ log 'backup complete'
+ logger -t backup -p local5.info 'backup complete'
+ '[' -n /backup/backup.log ']'
++ date
+ echo Mon Nov 14 13:56:25 EST 2011 'backup complete'
+ log '\===================='
+ logger -t backup -p local5.info '\===================='
+ '[' -n /backup/backup.log ']'
++ date
+ echo Mon Nov 14 13:56:25 EST 2011 '\===================='
sorry i'm a complete idiot when it comes to scripting. All help is appreciated great.
 
Old 11-14-2011, 02:04 PM   #2
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Original Poster
Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
for the INCLUDES portion of this script do i need to put each file on its own INCLUDE? as it appears to not be grabbing the files i want. I have made some modifications, but get the same results:

Code:
INCLUDES="hosts exports dhcpd.conf resolv.conf cups/printers.conf /sysconfig/static-routes /opt/ltsp/i386/etc/lts.conf /sysconfig/network-scripts/ifcfg-eth0 /sysconfig/network-scripts/ifcfg-eth0:0"
#### Below is the first attempt at INCLUDES, both sets give the same error
#INCLUDES="/etc/hosts /etc/exports /etc/dhcpd.conf /etc/resolv.conf /etc/cups/printers.conf /etc/sysconfig/static-routes /opt/ltsp/i386/etc/lts.conf /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0:0"
INCLUDES="$INCLUDES --include-form"
 
Old 11-14-2011, 02:25 PM   #3
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Original Poster
Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
so I commented out the INCLUDES section of the script and made a BACKUP_filter in the /bin directory, im still getting the following error:

Code:
+ rsync -aS -v --delete --include-form=BACKUP_filter 10.10.4.77:/ /backup/10.10.4.77/
rsync: --include-form=BACKUP_filter: unknown option
rsync error: syntax or usage error (code 1) at main.c(1231) [client=2.6.8]
the BACKUP_filter looks like:

Code:
# cat BACKUP_filter 
#
## BACKUP_filter
#
/etc/hosts
/etc/exports
/etc/dhcpd.conf
/etc/resolv.conf
/etc/cups/printers.conf
/etc/sysconfig/static-routes
/etc/sysconfig/network-scripts/ifcfg-eth0
/opt/ltsp/i386/etc/lts.conf
/etc/sysconfig/network-scripts/ifcfg-eth0:0
 
Old 11-14-2011, 03:17 PM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
First of all thanks for including complete shell script code (showing Simpsons' "INLCUDES" spelling error) and "-v" output, that helps a lot. While he uses a variable called "INCLUDES" the seemingly-rsync-equivalent "--includes=" doesn't exist: it's either "--include=" or "--include-from=". Same goes for your typo: it's not "--include-form=" but "--include-from=".
 
Old 11-14-2011, 03:23 PM   #5
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Original Poster
Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
ahh thank you. those typo's are mine, not his . I am the one who added the INCLUDES... I'll make the adjustment. So in short its --include-from not form... interesting. Thank you.
 
Old 11-14-2011, 03:43 PM   #6
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Original Poster
Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
kewl, thank you. Now I just need to go back and fix the dsa keys as it is asking for p/w again. That is easy enough to fix.
 
Old 11-14-2011, 04:51 PM   #7
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Original Poster
Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
Now that I have the dsa key fixed and the script is running. Next question. I only want to grab the files/directories listed above. I do not want an entire system backed up.

Code:
## BACKUP_filter
#
/etc/hosts
/etc/exports
/etc/dhcpd.conf
/etc/resolv.conf
/etc/cups/printers.conf
/etc/sysconfig/static-routes
/etc/sysconfig/network-scripts/ifcfg-eth0
/opt/ltsp/i386/etc/lts.conf
/etc/sysconfig/network-scripts/ifcfg-eth0:0
/usr/rx30
These are the only files/folders I want to backup not the entire computer.

Again thanks for the replies in advance.
 
Old 11-14-2011, 06:32 PM   #8
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by lleb View Post
I only want to grab the files/directories listed above. I do not want an entire system backed up.
Last time you've included information and output. You've been verbally rewarded for doing that. That should trigger a Pavlov reaction to always do that.
* BTW rsync has a nifty "-n" switch (think "--dry-run") with which you can test how things will go w/o actually fscking up your backup data.
 
Old 11-14-2011, 06:37 PM   #9
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Original Poster
Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
Again thank you for the reply, here is a directory list of what the first successful connection of the script grabbed and placed into the proper folder:

Code:
ls -laF /backup/10.10.4.77/
total 136
drwxr-xr-x  24 root root  4096 Nov 14 09:40 ./
drwxr-xr-x   3 root root  4096 Nov 14 11:15 ../
-rw-r--r--   1 root root     0 Nov 14 09:40 .autofsck
-rw-r--r--   1 root root     0 Nov 11 13:18 .autorelabel
-rw-r--r--   1 root root  4634 Nov 11 13:18 .swatch_script.1629
-rw-r--r--   1 root root  4634 Nov 14 09:40 .swatch_script.1645
-rw-r--r--   1 root root  4634 Nov 11 17:21 .swatch_script.1647
drwxr-xr-x   2 root root  4096 Nov 14 11:00 bin/
drwxr-xr-x   4 root root  4096 Nov 30  2010 boot/
drwxr-xr-x  12 root root  4096 Nov 14 09:41 dev/
drwxr-xr-x 101 root root 12288 Nov 14 09:40 etc/
drwxr-xr-x   2 root root  4096 Mar  9  2009 home/
drwxr-xr-x  13 root root  4096 Nov 11 14:28 lib/
drwx------   2 root root  4096 Nov 11 07:55 lost+found/
drwxr-xr-x   2 root root  4096 Mar  9  2009 media/
drwxr-xr-x   2 root root  4096 Nov 14 09:40 misc/
drwxr-xr-x   5 root root  4096 Nov 11 13:08 mnt/
drwxr-xr-x   2 root root  4096 Nov 14 09:40 net/
drwxr-xr-x   6 root root  4096 Apr  8  2011 opt/
dr-xr-xr-x 147 root root  4096 Nov 14 18:19 proc/
drwxr-x---   5 root root  4096 Nov 11 17:03 root/
drwxr-xr-x   2 root root 12288 Nov 11 14:30 sbin/
drwxr-xr-x   2 root root  4096 Nov 11 12:56 selinux/
drwxr-xr-x   2 root root  4096 Mar  9  2009 srv/
drwxr-xr-x  11 root root  4096 Nov 14 04:39 sys/
drwxr-xr-x   3 root root  4096 Nov 11 13:08 tftpboot/
drwxrwxrwx  16 root root  4096 Nov 14 17:25 tmp/
drwxr-xr-x  16 root root  4096 Nov 11 13:24 usr/
drwxr-xr-x  21 root root  4096 Nov 11 13:07 var/
As you can clearly see this grabbed way more then I desire.

here is the bash -v output:

Code:
# bash -x backup-servers -v
+ PATH=/usr/bin:/bin
+ BACKUPDIR=/backup
+ LOGFILE=/backup/backup.log
+ SERVERS=10.10.4.77
+ KEY=/root/.ssh/id_dsa_backup
+ EXCLUDES='/ /var/log /dev /proc /sys /tmp /var/tmp'
+ EXCLUDES='/ /var/log /dev /proc /sys /tmp /var/tmp /var/lib/pgsql/data /var/lib/mysql'
+ EXCLUDES='/ /var/log /dev /proc /sys /tmp /var/tmp /var/lib/pgsql/data /var/lib/mysql /var/qmail/queue /var/qmail/simscan'
+ MAILTO=postmaster@domain.xyz
+ export MAILTO
+ RSYNC_RSH='/usr/bin/ssh -i /root/.ssh/id_dsa_backup'
+ export RSYNC_RSH
+ unset SSH_AUTH_SOCK
+ '[' -v == -v ']'
+ OPTV=-v
+ EXC=
+ for e in '$EXCLUDES'
+ EXC=' --exclude=/'
+ for e in '$EXCLUDES'
+ EXC=' --exclude=/ --exclude=/var/log'
+ for e in '$EXCLUDES'
+ EXC=' --exclude=/ --exclude=/var/log --exclude=/dev'
+ for e in '$EXCLUDES'
+ EXC=' --exclude=/ --exclude=/var/log --exclude=/dev --exclude=/proc'
+ for e in '$EXCLUDES'
+ EXC=' --exclude=/ --exclude=/var/log --exclude=/dev --exclude=/proc --exclude=/sys'
+ for e in '$EXCLUDES'
+ EXC=' --exclude=/ --exclude=/var/log --exclude=/dev --exclude=/proc --exclude=/sys --exclude=/tmp'
+ for e in '$EXCLUDES'
+ EXC=' --exclude=/ --exclude=/var/log --exclude=/dev --exclude=/proc --exclude=/sys --exclude=/tmp --exclude=/var/tmp'
+ for e in '$EXCLUDES'
+ EXC=' --exclude=/ --exclude=/var/log --exclude=/dev --exclude=/proc --exclude=/sys --exclude=/tmp --exclude=/var/tmp --exclude=/var/lib/pgsql/data'
+ for e in '$EXCLUDES'
+ EXC=' --exclude=/ --exclude=/var/log --exclude=/dev --exclude=/proc --exclude=/sys --exclude=/tmp --exclude=/var/tmp --exclude=/var/lib/pgsql/data --exclude=/var/lib/mysql'
+ for e in '$EXCLUDES'
+ EXC=' --exclude=/ --exclude=/var/log --exclude=/dev --exclude=/proc --exclude=/sys --exclude=/tmp --exclude=/var/tmp --exclude=/var/lib/pgsql/data --exclude=/var/lib/mysql --exclude=/var/qmail/queue'
+ for e in '$EXCLUDES'
+ EXC=' --exclude=/ --exclude=/var/log --exclude=/dev --exclude=/proc --exclude=/sys --exclude=/tmp --exclude=/var/tmp --exclude=/var/lib/pgsql/data --exclude=/var/lib/mysql --exclude=/var/qmail/queue --exclude=/var/qmail/simscan'
+ log /====================
+ logger -t backup -p local5.info /====================
+ '[' -n /backup/backup.log ']'
++ date
+ echo Mon Nov 14 19:36:06 EST 2011 /====================
+ log 'backup-server -v starting'
+ logger -t backup -p local5.info 'backup-server -v starting'
+ '[' -n /backup/backup.log ']'
++ date
+ echo Mon Nov 14 19:36:06 EST 2011 'backup-server -v starting'
+ for SERVER in '$SERVERS'
+ TARGET=/backup/10.10.4.77
+ '[' '!' -d /backup/10.10.4.77 ']'
+ egrep -q '^rsync.*/backup/10.10.4.77' /proc/1/cmdline /proc/10/cmdline /proc/102/cmdline /proc/103/cmdline /proc/106/cmdline /proc/108/cmdline /proc/11/cmdline /proc/15/cmdline /proc/1576/cmdline /proc/16/cmdline /proc/17/cmdline /proc/176/cmdline /proc/177/cmdline /proc/179/cmdline /proc/180/cmdline /proc/181/cmdline /proc/1915/cmdline /proc/1916/cmdline /proc/1917/cmdline /proc/1947/cmdline /proc/1949/cmdline /proc/2/cmdline /proc/2182/cmdline /proc/2183/cmdline /proc/2388/cmdline /proc/2390/cmdline /proc/2412/cmdline /proc/2415/cmdline /proc/2436/cmdline /proc/2462/cmdline /proc/2463/cmdline /proc/2471/cmdline /proc/2490/cmdline /proc/2505/cmdline /proc/2514/cmdline /proc/2518/cmdline /proc/25225/cmdline /proc/25226/cmdline /proc/25251/cmdline /proc/25293/cmdline /proc/25296/cmdline /proc/25297/cmdline /proc/25304/cmdline /proc/2543/cmdline /proc/2579/cmdline /proc/2589/cmdline /proc/2602/cmdline /proc/2603/cmdline /proc/2611/cmdline /proc/2618/cmdline /proc/2626/cmdline /proc/2628/cmdline /proc/2630/cmdline /proc/2632/cmdline /proc/2634/cmdline /proc/2654/cmdline /proc/2679/cmdline /proc/2699/cmdline /proc/2708/cmdline /proc/2722/cmdline /proc/2734/cmdline /proc/2756/cmdline /proc/27675/cmdline /proc/27677/cmdline /proc/27681/cmdline /proc/27683/cmdline /proc/27685/cmdline /proc/27753/cmdline /proc/27756/cmdline /proc/27757/cmdline /proc/2776/cmdline /proc/2777/cmdline /proc/2778/cmdline /proc/2779/cmdline /proc/2780/cmdline /proc/2781/cmdline /proc/2782/cmdline /proc/2783/cmdline /proc/2784/cmdline /proc/2785/cmdline /proc/2788/cmdline /proc/27951/cmdline /proc/27952/cmdline /proc/2812/cmdline /proc/2821/cmdline /proc/2850/cmdline /proc/2859/cmdline /proc/2862/cmdline /proc/2879/cmdline /proc/2910/cmdline /proc/2911/cmdline /proc/2912/cmdline /proc/29467/cmdline /proc/2976/cmdline /proc/2988/cmdline /proc/2989/cmdline /proc/2990/cmdline /proc/2993/cmdline /proc/2995/cmdline /proc/2998/cmdline /proc/3/cmdline /proc/3000/cmdline /proc/30007/cmdline /proc/3017/cmdline /proc/3019/cmdline /proc/3022/cmdline /proc/3044/cmdline /proc/3081/cmdline /proc/3097/cmdline /proc/3098/cmdline /proc/3148/cmdline /proc/3152/cmdline /proc/3160/cmdline /proc/3162/cmdline /proc/3163/cmdline /proc/3167/cmdline /proc/3172/cmdline /proc/3186/cmdline /proc/3188/cmdline /proc/3193/cmdline /proc/3194/cmdline /proc/3197/cmdline /proc/3200/cmdline /proc/3201/cmdline /proc/3424/cmdline /proc/343/cmdline /proc/381/cmdline /proc/382/cmdline /proc/3854/cmdline /proc/3855/cmdline /proc/386/cmdline /proc/387/cmdline /proc/3870/cmdline /proc/388/cmdline /proc/3912/cmdline /proc/392/cmdline /proc/393/cmdline /proc/394/cmdline /proc/395/cmdline /proc/396/cmdline /proc/397/cmdline /proc/4/cmdline /proc/401/cmdline /proc/402/cmdline /proc/410/cmdline /proc/423/cmdline /proc/446/cmdline /proc/481/cmdline /proc/5/cmdline /proc/6/cmdline /proc/6122/cmdline /proc/7/cmdline /proc/8/cmdline /proc/9/cmdline /proc/self/cmdline
+ log '10.10.4.77 starting'
+ logger -t backup -p local5.info '10.10.4.77 starting'
+ '[' -n /backup/backup.log ']'
++ date
+ echo Mon Nov 14 19:36:06 EST 2011 '10.10.4.77 starting'
+ rsync -aS -v --delete --exclude=/ --exclude=/var/log --exclude=/dev --exclude=/proc --exclude=/sys --exclude=/tmp --exclude=/var/tmp --exclude=/var/lib/pgsql/data --exclude=/var/lib/mysql --exclude=/var/qmail/queue --exclude=/var/qmail/simscan --include-from=BACKUP_filter 10.10.4.77:/ /backup/10.10.4.77/
receiving file list ... done
usr/rx30/lifeline.que

sent 590 bytes  received 3366384 bytes  961992.57 bytes/sec
total size is 8412401337  speedup is 2498.50
+ rv=0
+ log '10.10.4.77 done rv=0'
+ logger -t backup -p local5.info '10.10.4.77 done rv=0'
+ '[' -n /backup/backup.log ']'
++ date
+ echo Mon Nov 14 19:36:09 EST 2011 '10.10.4.77 done rv=0'
+ log 'backup complete'
+ logger -t backup -p local5.info 'backup complete'
+ '[' -n /backup/backup.log ']'
++ date
+ echo Mon Nov 14 19:36:09 EST 2011 'backup complete'
+ log '\===================='
+ logger -t backup -p local5.info '\===================='
+ '[' -n /backup/backup.log ']'
++ date
+ echo Mon Nov 14 19:36:09 EST 2011 '\===================='
I also went so far as to add the following to the original script:

Code:
EXCLUDES="/ /var/log /dev /proc /sys /tmp /var/tmp"
EXCLUDES="$EXCLUDES /var/lib/pgsql/data /var/lib/mysql"
EXCLUDES="$EXCLUDES /var/qmail/queue /var/qmail/simscan"
from what i gather, and i could be way off base here, by adding the / and /var/log it should skip those files unless then are in the --include-from

is that not correct?

Last edited by lleb; 11-14-2011 at 06:39 PM.
 
Old 11-14-2011, 07:01 PM   #10
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Hmm. I'll have to get back to you on that one. To me it would make sense to just concentrate on rsyncing the subset of "/" (basically here your first root would be "/usr/rx30") and then rsync the /etc/ and /opt/ files in a separate run for now. I haven't used something like "--exclude=/", include a subset of "/" and then made it work OK.
 
Old 11-14-2011, 09:49 PM   #11
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Original Poster
Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
i would be more then happy to not use the exclude if i could get it to only grab the files and directories i desire.
 
Old 11-18-2011, 09:18 AM   #12
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Original Poster
Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
Instead of starting a new thread I will revive this one. I have a new script with -x -v output for some help.

the script:

Code:
 #!/bin/sh

###################################################
#  Atempt at a custom rsync for /usr/rx30
#
#
###############################################################################
#
# Copyright (C) 2005,2006,2007,2008 Ray Brunkow.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 or version 3 of the
# license, at your option.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
##############################################################################
#
# configuration

BACKUPDIR="/backup"

LOGFILE="$BACKUPDIR/backup.log"			# in addition to syslog
SERVERS="10.10.4.77"				# servers to be backed up

#
#
###############################################################################
#
# Start the log function
#
##############################################################################
function log() {
	logger -t backup -p local5.info "$@"

	if [ -n "${LOGFILE:-}" ]
	then
		echo `date` "$@" >> $LOGFILE
	fi
}

##########################################################
# make rsync use ssh with the correct key
RSYNC_RSH="/usr/bin/ssh -i $KEY"
export RSYNC_RSH
##########################################################
# make sure agent keys don't override the backup key
unset SSH_AUTH_SOCK

#########################################################
# if we were called with "-v", pass the "-v" along to rsync

if [ "$1" == "-v" ]
then
	OPTV="-v"
else
	OPTV=""
fi


########################################
#  Getting started

log '/===================='
log "backup-server $OPTV starting"

for SERVER in $SERVERS
do
	########################################
	# make sure target directory exists

	TARGET="$BACKUPDIR/$SERVER"

	if [ ! -d $TARGET ]
	then
		mkdir -p -m 0755 $TARGET
	fi

	########################################
	# make sure an earlier backup isn't already running

	if egrep -q "^rsync.*${TARGET}" /proc/*/cmdline > /dev/null 2>&1
	then
		log "$SERVER already in progress"
		continue
	fi

	########################################

##############################################################################
# rsync command without bandwidth limitations.  If you with to limit the bandwidth 
# uncomment out the line below:
##############################################################################

# rsync -avzpS --bwlimit=1024 -e "ssh -i /root/.ssh/id_dsa_backup" root@10.10.4.77:/usr/rx30 /backup/10.10.4.77/ -v

 rsync -avzpS $OPTV /usr/rx30:/ ${TARGET}/ -v
# rsync -avzpS -e "ssh -i /root/.ssh/id_dsa_backup" root@10.10.4.77:/usr/rx30 /backup/10.10.4.77/ -v
rv=$?
	log "$SERVER done rv=$rv"

done

log "backup complete"
log '\===================='


################################################################
# end log process and write file to backup up server
################################################################
and now for the -v output:

Code:
bash -x rx30_backup -v
+ BACKUPDIR=/backup
+ LOGFILE=/backup/backup.log
+ SERVERS=10.10.4.77
+ RSYNC_RSH='/usr/bin/ssh -i '
+ export RSYNC_RSH
+ unset SSH_AUTH_SOCK
+ '[' -v == -v ']'
+ OPTV=-v
+ log /====================
+ logger -t backup -p local5.info /====================
+ '[' -n /backup/backup.log ']'
++ date
+ echo Fri Nov 18 10:17:21 EST 2011 /====================
+ log 'backup-server -v starting'
+ logger -t backup -p local5.info 'backup-server -v starting'
+ '[' -n /backup/backup.log ']'
++ date
+ echo Fri Nov 18 10:17:21 EST 2011 'backup-server -v starting'
+ for SERVER in '$SERVERS'
+ TARGET=/backup/10.10.4.77
+ '[' '!' -d /backup/10.10.4.77 ']'
+ egrep -q '^rsync.*/backup/10.10.4.77' /proc/1/cmdline /proc/10/cmdline /proc/102/cmdline /proc/103/cmdline /proc/106/cmdline /proc/108/cmdline /proc/11/cmdline /proc/11051/cmdline /proc/12938/cmdline /proc/14999/cmdline /proc/15/cmdline /proc/15001/cmdline /proc/15037/cmdline /proc/15078/cmdline /proc/15081/cmdline /proc/15083/cmdline /proc/15092/cmdline /proc/1544/cmdline /proc/16/cmdline /proc/17/cmdline /proc/176/cmdline /proc/177/cmdline /proc/178/cmdline /proc/179/cmdline /proc/180/cmdline /proc/181/cmdline /proc/1912/cmdline /proc/1913/cmdline /proc/1914/cmdline /proc/1944/cmdline /proc/1946/cmdline /proc/2/cmdline /proc/20058/cmdline /proc/20059/cmdline /proc/20688/cmdline /proc/2180/cmdline /proc/2181/cmdline /proc/2386/cmdline /proc/2388/cmdline /proc/2410/cmdline /proc/2413/cmdline /proc/2434/cmdline /proc/2461/cmdline /proc/2462/cmdline /proc/2469/cmdline /proc/2488/cmdline /proc/2503/cmdline /proc/2512/cmdline /proc/2516/cmdline /proc/2539/cmdline /proc/2577/cmdline /proc/2587/cmdline /proc/2600/cmdline /proc/2601/cmdline /proc/2610/cmdline /proc/2616/cmdline /proc/2624/cmdline /proc/2626/cmdline /proc/2628/cmdline /proc/2630/cmdline /proc/2632/cmdline /proc/2652/cmdline /proc/2677/cmdline /proc/2697/cmdline /proc/2706/cmdline /proc/2720/cmdline /proc/2732/cmdline /proc/2754/cmdline /proc/2774/cmdline /proc/2775/cmdline /proc/2776/cmdline /proc/2777/cmdline /proc/2778/cmdline /proc/2779/cmdline /proc/2780/cmdline /proc/2781/cmdline /proc/2782/cmdline /proc/2783/cmdline /proc/2786/cmdline /proc/2810/cmdline /proc/2819/cmdline /proc/2848/cmdline /proc/2857/cmdline /proc/2860/cmdline /proc/2877/cmdline /proc/2908/cmdline /proc/2909/cmdline /proc/2910/cmdline /proc/2974/cmdline /proc/2985/cmdline /proc/2986/cmdline /proc/2987/cmdline /proc/2988/cmdline /proc/2993/cmdline /proc/2994/cmdline /proc/3/cmdline /proc/3000/cmdline /proc/3014/cmdline /proc/3016/cmdline /proc/3019/cmdline /proc/3043/cmdline /proc/3080/cmdline /proc/3096/cmdline /proc/3097/cmdline /proc/3156/cmdline /proc/3161/cmdline /proc/3163/cmdline /proc/3165/cmdline /proc/3172/cmdline /proc/3174/cmdline /proc/3175/cmdline /proc/3177/cmdline /proc/3182/cmdline /proc/3187/cmdline /proc/3198/cmdline /proc/3200/cmdline /proc/3205/cmdline /proc/3206/cmdline /proc/3209/cmdline /proc/3212/cmdline /proc/3214/cmdline /proc/3303/cmdline /proc/3305/cmdline /proc/3306/cmdline /proc/3320/cmdline /proc/3321/cmdline /proc/343/cmdline /proc/381/cmdline /proc/382/cmdline /proc/386/cmdline /proc/387/cmdline /proc/388/cmdline /proc/392/cmdline /proc/393/cmdline /proc/394/cmdline /proc/395/cmdline /proc/396/cmdline /proc/397/cmdline /proc/4/cmdline /proc/401/cmdline /proc/402/cmdline /proc/410/cmdline /proc/423/cmdline /proc/446/cmdline /proc/4612/cmdline /proc/4613/cmdline /proc/4639/cmdline /proc/4689/cmdline /proc/481/cmdline /proc/5/cmdline /proc/6/cmdline /proc/7/cmdline /proc/8/cmdline /proc/9/cmdline /proc/self/cmdline
+ rsync -avzpS -v /usr/rx30:/ /backup/10.10.4.77/ -v
building file list ... 
rsync: link_stat "/usr/rx30:/." failed: No such file or directory (2)
done
send_file_list done
send_files starting
server_recv(2) starting pid=20695
received 0 names
recv_file_list done
get_local_name count=0 /backup/10.10.4.77/
recv_files(0) starting
generator starting pid=20695 count=0
delta-transmission disabled for local transfer or --whole-file
generate_files phase=1
send_files phase=1
recv_files phase=1
generate_files phase=2
send_files phase=2
send files finished
total: matches=0  hash_hits=0  false_alarms=0 data=0
recv_files phase=2
recv_files finished
generate_files phase=3
generate_files finished

sent 29 bytes  received 20 bytes  98.00 bytes/sec
total size is 0  speedup is 0.00
rsync error: some files could not be transferred (code 23) at main.c(892) [sender=2.6.8]
_exit_cleanup(code=23, file=main.c, line=892): about to call exit(23)
+ rv=23
+ log '10.10.4.77 done rv=23'
+ logger -t backup -p local5.info '10.10.4.77 done rv=23'
+ '[' -n /backup/backup.log ']'
++ date
+ echo Fri Nov 18 10:17:21 EST 2011 '10.10.4.77 done rv=23'
+ log 'backup complete'
+ logger -t backup -p local5.info 'backup complete'
+ '[' -n /backup/backup.log ']'
++ date
+ echo Fri Nov 18 10:17:21 EST 2011 'backup complete'
+ log '\===================='
+ logger -t backup -p local5.info '\===================='
+ '[' -n /backup/backup.log ']'
++ date
+ echo Fri Nov 18 10:17:21 EST 2011 '\===================='
again, thanks in advance.

also a note, the
# rsync -avzpS -e "ssh -i /root/.ssh/id_dsa_backup" root@10.10.4.77:/usr/rx30 /backup/10.10.4.77/ -v

functions properly, im trying to add the logging function.

Last edited by lleb; 11-18-2011 at 09:34 AM.
 
Old 11-18-2011, 10:20 AM   #13
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by lleb View Post
functions properly, im trying to add the logging function.
If you just want to add logging why not use rsync with "--log-file=/path/to/rsync.log --log-file-format="%t\n";"?
 
Old 11-18-2011, 11:41 AM   #14
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Original Poster
Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
Quote:
Originally Posted by unSpawn View Post
If you just want to add logging why not use rsync with "--log-file=/path/to/rsync.log --log-file-format="%t\n";"?
i will try that, thank you.
 
Old 11-18-2011, 11:44 AM   #15
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Original Poster
Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
hmm, im sure i entered that wrong:

Code:
rsync -avzpS -e --log-file=/backup/backup.log --log-file-format="%t/n";" "ssh -i /roo
t/.ssh/id_dsa_backup" root@10.10.4.77:/usr/rx30 /backup/10.10.4.77/ -v
this just prompted a > to the left of the terminal window like it was looking for further arguments.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
I cant get crontab to execute my rsync script.... Theatre Linux - Server 3 09-10-2011 05:19 AM
find & rsync script simon_bagola Linux - Newbie 13 01-15-2011 07:33 AM
Question on rsync script, not doing what it should be doing... JockVSJock Programming 5 01-03-2010 02:07 PM
local rsync shell script eradrix Programming 13 07-09-2005 12:57 AM
rsync script twantrd Programming 2 01-06-2005 05:46 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration