Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using rsync to make backups. During the backup process, the following rsync command is used to check how many files have been changed:

rsync --dry-run --stats -a /path/to/source/dir/ /path/to/destination/dir/

The command gives me output similar to this:

Number of files: 3
Number of files transferred: 1
Total file size: 6 bytes
Total transferred file size: 6 bytes
Literal data: 0 bytes
Matched data: 0 bytes
File list size: 80
File list generation time: 0.001 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 104
Total bytes received: 23

sent 104 bytes  received 23 bytes  254.00 bytes/sec
total size is 6  speedup is 0.05 (DRY RUN)

I can then parse this text and retrieve data about how many files need to be transfered and total file size needed to be transfered. Based on that I will decide whether I need to make a backup.

Here are my questions:

  1. Is there any way how to find out how many directories (not files) have been created/deleted in the source directory since last backup?
  2. How can I find out how many files have been deleted in the source directory since last backup?

There is no need to use rsync for this. I'm fine with other tools to be used. I'm just looking for simple and fast way to do this.

share|improve this question

Add the -i (itemize-changes) and --delete-delay option in rsync. It will list the files and directories that will be deleted and/or to be created. You can then parse this output to achieve what you want.

share|improve this answer

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.