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 Answers1

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}}'
Dennis Williamson
  • 62,149
  • 16
  • 116
  • 151
  • 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 –  May 03 '10 at 02:58
  • @Mirage: See my edited answer. – Dennis Williamson May 03 '10 at 03: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 –  May 03 '10 at 04: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 03 '10 at 05: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 –  May 03 '10 at 06:18