title: How could I lock a directory?
body: <p>I'm making backups with <code>rsnapshot</code>. The path to the backups looks like this:</p>
  
  <pre><code>name=$(date +"%Y-%m-%d_%H-%M")
  /backup/hourly.0/"$name"
  </code></pre>
  
  <p>In a perl script I choose from the the different snapshots to make <code>diffs</code> to the files in my home directory.</p>
  
  <pre><code>my $backup = '/backup';
  
  opendir my $dh, $backup or die $!;
  my @versions;
  while ( defined( my $version = readdir $dh ) ) {
      # ...
      push @versions, $version;
  }
  # choose from @versions
  # do something with the choosen
  </code></pre>
  
  <p>Is there a way to lock the backup directory, so that <code>rsnapshot</code> doesn't begin to rotate the snapshots while I am running my script?</p>