Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I am using rsync to backup the files.

I want that after backup i should get the following info

1)No of FIles copied 2)No of file deleted in destination 3)How much data copies

and nothing else

If i use quiet mode then i get no info but if i don't then i get all the files info as well which is very long

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Some of that information will be output by the --stats option.

You can use the command below to count the deleted files. It also suppresses the output of the copied filenames. You may need to modify it to match the output of your particular rsync option selection. I've included a simple rsync command as an example. Note that the --stats and --verbose options are required for this to work.

rsync --archive --delete --stats --verbose from to | \
awk 'BEGIN {count = flag = 0} \
    /^deleting/ {count++; next} \
    /^Number of files: [0-9]*$/ {flag=1; print "Files deleted: " count} \
    {if (flag == 1) {print}}'
share|improve this answer
    
but if i use quite mde then it don't display anything but if i don't then i get all list of files copies that too long –  John May 3 '10 at 2:58
    
@Mirage: See my edited answer. –  Dennis Williamson May 3 '10 at 3:02
    
thanks for that i will try that –  John May 3 '10 at 4:25
    
Can i put that awk programming lines inside a file for better viewing inside crontab. DO i have to write "from to" in the command as well –  John May 3 '10 at 4:41
    
@Mirage: No, "from" and "to" just represent the source and destination in my example. You would use the ones you normally would (plus any other options and arguments you need (except for --quiet). Yes, you can create a script file out of the awk command. –  Dennis Williamson May 3 '10 at 5:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.