spravne reseni:
viz http://stackoverflow.com/questions/21148145/rsync-command-with-filter-in-a-bash-variable
RSYNCCMD=rsync
RSYNCOPTS=(-aHx --delete \
--exclude '*/.beagle*' \
--exclude '*/.gvfs/*' \
--exclude '*/.google/*' \
--exclude '*.gconf*' \
--exclude '*/[Cc]ache/*' \
--exclude '*/.[Cc]ache/*' \
--exclude '*/sysel*/*' \
--exclude '*/[Tt]rash/*' \
--exclude 'cyril/tmp/*' \
--exclude 'cyril/.thumbnails/*' \
--exclude 'cyril/.opera/images/*' \
--exclude 'cyril/.opera/opcache/*' \
--exclude 'cyril/.nautilus/metafiles/*')
$RSYNCCMD "${RSYNCOPTS[@]}" /home/cyril "$TGT"
problem s .gvfs:
reseni 1 :
RSYNCCMD="rsync -aHP --delete --max-size=4G \
--exclude 'tmp/*' \
--exclude 'var/tmp/*' \
--exclude 'var/lock/*' \
--exclude 'var/lib/ntp/proc*' \
--exclude 'var/crash/*' \
--exclude '*/[Cc]ache/*' \
--exclude '*/.opera/opcache/*' \
--exclude '*/.[Cc]ache/*' \
--exclude '.[Cc]ache/*' \
--exclude '*/.gvfs' \
--exclude '.gvfs' \
--exclude '*/.opera/icons/*' \
--exclude '*/.thumbnails/*' \
--exclude '.thumbnails/*' \
--exclude '*.beagle*' \
--one-file-system "
eval $RSYNCCMD / "$TGT" && tgt1="ok"
eval $RSYNCCMD /opt/ "$TGT"/opt && tgt2="ok"
for i in `ls /home` ; do
if grep -q $i /etc/passwd ;
then # echo $i je uzivatel ;
sudo -u $i $RSYNCCMD /home/$i/ "$TGT"/home/$i && tgt3="$tgt3 + $i ok" && echo zaloha $i provedena `date`
else #echo $i neni ;
eval $RSYNCCMD /home/$i/ "$TGT"/home/$i && tgt3="$tgt3 + $i ok" && echo zaloha $i provedena `date`
fi ;
done
ale proste v RSYNCCMD se --exclude=*/.gvfs neprovede.
Resni 2:
(sysel 10.3. 2014)
$RSYNCCMD --exclude='*/.gvfs' / "$TGT" && STATUS1=OK
Nicmene, RSYNCCMD je podle me definovan spatne.
========================
skript /root/rsync-zaloha.sh , kde v root jsou externi filesystemy namountovane /maiboxes a /data:
#!/bin/bash
LOCKF=/var/lock/rsync-zaloha.lock
TGT="sever.cz::modul"
# Create empty lock file if none exists
touch $LOCKF
# Read the content of the lockfile into a variable
read lastPID < $LOCKF
# If lastPID is not null and a process with that pid exists, exit the script
[ ! -z "$lastPID" -a -d /proc/$lastPID ] && { echo 'Locked: Another process is running' ; exit 1; }
# Write the PID of the current running script to the lock file
echo $$ > $LOCKF
echo :::: `date` start ::::::::::::::::::::::::::::::::::::::::::::::::
OPTS="-aHx --delete"
EXCL=(--exclude '/tmp/' --exclude '/var/tmp/' --exclude '/mailboxes/' --exclude '/data/')
echo `date`" rsync $OPTS "${EXCL[@]}" / ${TGT}/"
nice /usr/bin/rsync $OPTS "${EXCL[@]}" / ${TGT}/
echo `date`" rsync $OPTS /mailboxes/ ${TGT}/mailboxes/"
nice /usr/bin/rsync $OPTS /mailboxes/ ${TGT}/mailboxes/
echo `date`" rsync $OPTS /data/ ${TGT}/data/"
nice /usr/bin/rsync $OPTS /data/ ${TGT}/data/
rm -f $LOCKF
echo :::: `date` stop ::::::::::::::::::::::::::::::::::::::::::::::::
Žádné komentáře:
Okomentovat