diff --git a/storage/backend/backend.go b/storage/backend/backend.go
index <HASH>..<HASH> 100644
--- a/storage/backend/backend.go
+++ b/storage/backend/backend.go
@@ -295,6 +295,7 @@ func defragdb(odb, tmpdb *bolt.DB, limit int) error {
 					return err
 				}
 				tmpb = tmptx.Bucket(next)
+				count = 0
 			}
 			err = tmpb.Put(k, v)
 			if err != nil {
backend: reset count in defrg