- run a backup job
- The jobs creates partial files one after the other, about 2 minutes interval.
What i want to do is that while the job is still running or while a file was last modified or created 3 minutes ago, the
file should be rsync to a remote server untill the last file has been created and 3 minutes old.
I am learning how to script.
I have tried different options but no success
The closest i got was that the files were copied up to the current last file created and the script exited without waiting for the subsequent files to be created.
In other words i could not get the script to loop until it picked up all the files before exiting.
In my test i used ' echo " nohup rsync -a --inplace /mara/backup/mala$filename mara@tronic9922:/mara/backup/mara/ $ " >> thejobs ' instead of doing rsync dynamically.
But what i really need is to use rsync, to i can send each file to the remove server as it is created and its is 3 minutes old.
Hopefully someone can fix this for me or come up with a new script all together.
- see bottom for the files that get created.
Thanks
#!/bin/ksh
for filename in `find . -mmin -3 -type f|grep bkup`;
do
BKPPROCCNT=`ps -ef |grep "/royal/current/bin/_muller runbkup"|grep -v grep |wc -l` echo $filename
if [[ $BKPPROCCNT -eq 1 ]] || [[ -s $filename ]];
then
nohup rsync -a --inplace /home/backup/mala/$filename mala@tronic9922:/home/backup/mala/ $
else
fi
sleep 3
done
#!/bin/ksh
for filename in `find . -mmin +2 -type f|grep bkup`;
do
BKPPROCCNT=`ps -ef |grep "/royal/current/bin/_muller runbkup"|grep -v grep |wc -l`
echo $filename
if [[ $BKPPROCCNT -eq 1 ]] && [[ -s $filename ]];
then
nohup rsync -a --inplace /home/backup/mala$filename mala@tronic9922:/home/backup/mala/ $
else
echo "backup ended or no file found"
fi
sleep
done
TRYING TO USE A WHILE LOOP AS THE BACKUP JOB IS RUNNING - this i could not figure it out.
#!/bin/ksh
set BKPID = `ps -ef |grep "/royal/current/bin/_muller runbkup"|awk '{print $2}'|head -1`
while ("$BKID" != "")
do
if [ test `find /vpas/backup/mala -name bkup* -mmin +5` ] then
then
---
nohup rsync -a --inplace /home/backup/mala$filename mala@tronic9922:/home/backup/mala/ $
else
echo "backup ended or no file found"
fi
sleep 3
done
cd /home/backup/mala
ls -lrt
-rw-rw-r-- 1 mala dev 7516081152 Apr 11 19:50 bkup1
-rw-rw-r-- 1 mala dev 7516081152 Apr 11 19:51 bkup2
-rw-rw-r-- 1 mala dev 7516081152 Apr 11 19:52 bkup3
-rw-rw-r-- 1 mala dev 7516081152 Apr 11 19:53 bkup4
-rw-rw-r-- 1 mala dev 7516081152 Apr 11 19:55 bkup5
-rw-rw-r-- 1 mala dev 7516081152 Apr 11 19:56 bkup6
-rw-rw-r-- 1 mala dev 7516081152 Apr 11 19:57 bkup7
-rw-rw-r-- 1 mala dev 7516081152 Apr 11 19:57 bkup8
-rw-rw-r-- 1 mala dev 7516081152 Apr 11 19:58 bkup9
-rw-rw-r-- 1 mala dev 7516081152 Apr 11 19:59 bkup10
-rw-rw-r-- 1 mala dev 3943402496 Apr 11 19:59 bkup11