diff --git a/handlers/rsync.in b/handlers/rsync.in
index ab6496fb6624765fbd823c69d2010e90fd9ecd7c..f1406427f9f96f3de716831348267e914b5065da 100644
--- a/handlers/rsync.in
+++ b/handlers/rsync.in
@@ -317,6 +317,14 @@ function rotate_short {
     $nice $cp -alf /$folder.1/. /$folder.0
   fi
 
+  # Cleanup orphaned metadata
+  for file in `ls $metadata`; do
+    if [ ! -d "`dirname $folder`/$file" ]; then
+      debug "removing orphaned metadata $file"
+      rm -rf $metadata/$file
+    fi
+  done
+
 }
 
 function rotate_short_remote {
@@ -355,6 +363,14 @@ function rotate_short_remote {
   if [ -d $folder.1 ]; then
     $nice $cp -alf /$folder.1/. /$folder.0
   fi
+
+  # Cleanup orphaned metadata
+  for file in `ls $metadata`; do
+    if [ ! -d "`dirname $folder`/\$file" ]; then
+      debug "removing orphaned metadata \$file"
+      rm -rf $metadata/\$file
+    fi
+  done
   ##### END REMOTE SCRIPT #######
 EOF
 ) | (while read a; do passthru $a; done)
@@ -466,6 +482,14 @@ function rotate_long {
     done
   done
 
+  # Cleanup orphaned metadata
+  for file in `ls $backuproot/metadata`; do
+    if [ ! -d "$backuproot/$file" ]; then
+      debug "removing orphaned metadata $file"
+      rm -rf $backuproot/metadata/$file
+    fi
+  done
+
 }
 
 function rotate_long_remote {
@@ -575,6 +599,14 @@ function rotate_long_remote {
       fi
     done
   done
+
+  # Cleanup orphaned metadata
+  for file in `ls $backuproot/metadata`; do
+    if [ ! -d "$backuproot/\$file" ]; then
+      debug "removing orphaned metadata \$file"
+      rm -rf $backuproot/metadata/\$file
+    fi
+  done
   ##### END REMOTE SCRIPT #######
 EOF
 ) | (while read a; do passthru $a; done)