1

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

1

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}}'
  • 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
  • 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
  • Is it possible to to insert that parsed data in MYSQL database in one step only. I mean i don't want to create a file , then read file and then insert. Just like u AWKED – John May 3 '10 at 6:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy