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 04-04-2005, 08:04 PM   #1
s_siouris
LQ Newbie
 
Registered: Nov 2004
Distribution: Scientific Linux 6.4
Posts: 22

Rep: Reputation: 0
Post rsync skipping files


Hi,
I wrote a bash script for updating either my pc at home, or my pc at work (either one can be the target or source), but rsync always skips files resulting in the target directory having less files than the source. I basically don't know if there is a problem with my script, or if it's to do with rsync. I read that rsync doesn't behave properly when there are a lot of arguments, so I am only using two or three arguments, but I am stil getting that problem.

Here's the script I wrote:
Code:
#!/bin/bash

wa_zeus=warehouse
wa_home=warehouse

d[1]=bookmarks
d[2]=cics
d[3]=docs
d[4]=ga-codes
d[5]=linux
d[6]=manuals
d[7]=papers
d[8]=personal
d[9]=programming-c
d[10]=programming-fortran


zeus=xxxxxx@xxxxxxxxxx     # username and ip of the remote pc

echo ' Choose which workstation to bring up to date:'
echo ' zeus --> home box, press 1'
echo ' home box --> zeus, press 2'
echo ' anything else exits this script.'; read choice
echo ' you chose' $choice

if [ "$choice" = 1 ]
then
        for index in 1 2 3 4 5 6 7 8 9 10
        do
                echo
                echo 'now rsync-ing '${d[index]}
                rsync -r -z --delete --progress $zeus:/$wa_zeus/${d[index]}/* /$wa_home/${d[index]}/
        done
        echo 'All done!'
elif [ "$choice" = 2 ]
then
        for index in 1 2 3 4 5 6 7 8 9 10
        do
                echo
                echo 'now rsync-ing '${d[index]}
                rsync -r -z --delete --progress /$wa_home/${d[index]}/* $zeus:/$wa_zeus/${d[index]}/
        done
        echo 'All done!'
else
        echo 'You chose to exit'
fi

exit

By the way, does anybody know a quick way to write a "for" loop in bash that will recurse into directories? (wondering about this for another script of mine).

Thanks
Spiros
 
Old 04-05-2005, 10:10 AM   #2
Technoslave
Member
 
Registered: Dec 2003
Location: Northern VA
Posts: 493

Rep: Reputation: 30
Well, the way you're doing your rsync looks right, although, that's not how I would have done it, so I can't be 100% sure of it's accuracy. Also, you might try putting a -x at the end of #!/bin/bash, that will give you more output when you run the command, you might be able to debug the issue that way.

Also, for your rsync, depending on what type of connection you have, you might want to include the --no-whole-file option.

As for your for loop, it's a kludge, but you could do something like:

for i in `ls */*.txt`; do echo $i;done

Something like that. Hopefully, someone will have a cleaner solution to that.
 
Old 04-05-2005, 03:10 PM   #3
s_siouris
LQ Newbie
 
Registered: Nov 2004
Distribution: Scientific Linux 6.4
Posts: 22

Original Poster
Rep: Reputation: 0
thanks for you rreply,

the reason I have done my rsync this way is because I don't want to syncronise all the directories, but only a few ones (which I can easily add/remove as values of the array), so I can't think of any other way of doing this easily. I could open and read a file containing the list of directories I want to synchronise, but this just adds complexity without real gains.

Could you please explain your suggestion for the for loop?
for i in `ls */*.txt`; do echo $i;done
I assume that the 'ls */*.txt' is a command and `pipes' to the value for `i' (correct?). I tried that ls command on a shell but it didn't work. I understand what `ls *.txt' does, but not the 'ls */*.txt'.

thanks
Spiros
 
Old 04-05-2005, 04:34 PM   #4
s_siouris
LQ Newbie
 
Registered: Nov 2004
Distribution: Scientific Linux 6.4
Posts: 22

Original Poster
Rep: Reputation: 0
I've just found the problem... I was making a stupid mistake...
Basically the count from rsync for the files to be considered includes folders, but these aren't actually transfered rather than `created' in the target box. This is why the actual transfer number of files was always less than the total amount of `files' (ie files+directories)

Thanks for your help anyway
Spiros
 
Old 04-06-2005, 11:00 AM   #5
Technoslave
Member
 
Registered: Dec 2003
Location: Northern VA
Posts: 493

Rep: Reputation: 30
Sure, I know what you mean with the folders and the like.

As for my quick script.

If you were to do an ls -l */*.txt, you'd get all the files that are in one level of folder down that end in *.txt, likewise you could */*/*.txt, which would go 2 folder levels down. Like I said, a kludge, the echo $i is just to tell you what the file is named in the iterative process of the script.
 
  


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
rsync: only backup recently modified files hamish Linux - Software 3 09-20-2011 09:55 AM
rsync files accessed under 30 days 0ddba11 Linux - General 3 11-03-2005 06:59 AM
RSYNC and dot files Buto Linux - General 1 09-22-2005 02:39 PM
Critical Error: dist-upgrade skipping files. rvijay Debian 4 02-27-2005 01:03 PM
FC2 test 3 mouse skipping a beat, movie skipping also jang Fedora 1 10-28-2004 07:42 PM

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

All times are GMT -5. The time now is 03:20 PM.

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