# Pitr restoration not working properly - Mongodb operator version : 7.0.8-5

**URL:** https://forums.percona.com/t/pitr-restoration-not-working-properly-mongodb-operator-version-7-0-8-5/36054
**Category:** MongoDB
**Created:** [January 9, 2025, 11:55am UTC](https://forums.percona.com/t/pitr-restoration-not-working-properly-mongodb-operator-version-7-0-8-5/36054 "2025-01-09T11:55:51Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![gowtham-ji](https://avatars.discourse-cdn.com/v4/letter/g/3d9bf3/32.png) [@gowtham-ji](https://forums.percona.com/u/gowtham-ji)
#### Post date: [January 9, 2025, 11:55am UTC](https://forums.percona.com/t/pitr-restoration-not-working-properly-mongodb-operator-version-7-0-8-5/36054/1 "2025-01-09T11:55:51Z")

</div>

**Case 1** :  
DB Creation and Data Addition:

Created db1 and collection1 under db1.

Added 1 GB of documents to collection1 at 11 AM.

Added another 1 GB of documents to collection1 at 2 PM.

**PITR Restore** :

Restored data as of 12:30 PM using PITR.

**Outcome:**  
Since the restoration point is 12:30 PM, only the first 1 GB of documents added at 11 AM are present in collection1.

The second set of documents added at 2 PM are not included because the restoration point is before this time.

**Case 2** :  
DB and Collection Creation and Data Addition:

Created db2 and collection1 under db2.

Added 1 GB of documents to collection1 at 11 AM.

Created collection2 under db2.

Added 1 GB of documents to collection2 at 2 PM.

**PITR Restore:**

Restored data as of 12:30 PM using PITR.

**Outcome**

As of 12:30 PM, collection1 had only 1 GB of documents. But I could see both collection1 and collection 2 are present.

**Expected Result:**

collection1 only should present Since the restoration point is 12:30 PM

---

<div class="post-metadata">

### Author: ![Peter\_Szczepaniak](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/peter_szczepaniak/32/21329_2.png) [@Peter\_Szczepaniak](https://forums.percona.com/u/Peter_Szczepaniak)
#### Post date: [January 9, 2025, 2:09pm UTC](https://forums.percona.com/t/pitr-restoration-not-working-properly-mongodb-operator-version-7-0-8-5/36054/2 "2025-01-09T14:09:22Z")

</div>

Hi @gowtham-ji

Thank you for the feedback! In your first case you are modifying the same collection hence the PITR working as expected but in the second you created second collection and Mongo during restore doesn’t remove collection if it’s present.

---

<div class="post-metadata">

### Author: ![gowtham-ji](https://avatars.discourse-cdn.com/v4/letter/g/3d9bf3/32.png) [@gowtham-ji](https://forums.percona.com/u/gowtham-ji)
#### Post date: [January 9, 2025, 2:29pm UTC](https://forums.percona.com/t/pitr-restoration-not-working-properly-mongodb-operator-version-7-0-8-5/36054/3 "2025-01-09T14:29:40Z")

</div>

Hi @Peter_Szczepaniak

It means during restore pitr doesn’t remove collection if its present even if the restoration point is before the collection creation. But pitr removes the changes made in the collection after restoration point. This is how pitr works in mongodb right?

---

<div class="post-metadata">

### Author: ![Diogo\_Recharte](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/diogo_recharte/32/8004_2.png) [@Diogo\_Recharte](https://forums.percona.com/u/Diogo_Recharte)
#### Post date: [January 9, 2025, 2:51pm UTC](https://forums.percona.com/t/pitr-restoration-not-working-properly-mongodb-operator-version-7-0-8-5/36054/4 "2025-01-09T14:51:09Z")

</div>

This is not just about PITR, you would see exactly the same behavior even if you had done a full **logical** backup.  
By design, restoring a logical backup only restores whichever collections are backed up, leaving the others as is.

Allow me to elaborate with an example using full backups (without PITR):

1. DB created
2. Load first collection (A)
3. DB backup
4. Load second collection (B)
5. Restore DB back to the backup (3.)

Collection A was part of the logical backup but collection B was not. When restoring the backup, any changes to collection A that took place after the backup would be reverted, as expected. However, since we introduced an entirely new collection B, that isn’t part of the backup, this one won’t be reverted.  
This is a design decision of logical backups/restores, i.e. non-backed up collections not getting deleted is expected behavior.

If users want a complete file system restore (non-backed up collections to be deleted), they must take a physical backup.

---

<div class="post-metadata">

### Author: ![gowtham-ji](https://avatars.discourse-cdn.com/v4/letter/g/3d9bf3/32.png) [@gowtham-ji](https://forums.percona.com/u/gowtham-ji)
#### Post date: [January 9, 2025, 2:58pm UTC](https://forums.percona.com/t/pitr-restoration-not-working-properly-mongodb-operator-version-7-0-8-5/36054/5 "2025-01-09T14:58:32Z")

</div>

Hi @Diogo_Recharte  
I noticed the same thing during logical backup aswell.  
Thanks for the clarification!

---

<div class="post-metadata">

### Author: ![gowtham-ji](https://avatars.discourse-cdn.com/v4/letter/g/3d9bf3/32.png) [@gowtham-ji](https://forums.percona.com/u/gowtham-ji)
#### Post date: [January 10, 2025, 12:46pm UTC](https://forums.percona.com/t/pitr-restoration-not-working-properly-mongodb-operator-version-7-0-8-5/36054/6 "2025-01-10T12:46:39Z")

</div>

Hi @Diogo_Recharte

**Before full logical backup database status**

admin 13.34 MiB  
config 3.61 MiB  
doublecollection 94.25 MiB  
pitr 95.52 MiB  
restore 259.36 MiB  
restore-test-1 94.63 MiB  
singlecollection 40.00 KiB  
test1db 306.50 MiB  
withoutcollections 40.00 KiB

**after Full Logical backup I created collection1 db and added ducuments to the collection1 under collection1 db**

[direct: mongos] collection1\> show collections  
collection1

**collection1 size:**

sharded: false,  
size: 426,  
count: 9,  
numOrphanDocs: 0,  
storageSize: 36864,  
totalIndexSize: 36864,  
totalSize: 73728,  
indexSizes: { _id_: 36864 },  
avgObjSize: 47,  
ns: ‘collection1.collection1’,  
nindexes: 1,  
scaleFactor: 1

**database status**

[direct: mongos] test\> show dbs  
admin 13.34 MiB  
**collection1 72.00 KiB**  
config 3.61 MiB  
doublecollection 94.25 MiB  
pitr 95.52 MiB  
restore 259.36 MiB  
restore-test-1 94.63 MiB  
singlecollection 40.00 KiB  
test1db 306.50 MiB  
withoutcollections 40.00 KiB

**After restored from full logical backup database status**

[direct: mongos] test\> show dbs  
admin 13.34 MiB  
**collection1 72.00 KiB**  
config 3.61 MiB  
doublecollection 94.25 MiB  
pitr 95.52 MiB  
restore 259.36 MiB  
restore-test-1 94.63 MiB  
singlecollection 40.00 KiB  
test1db 306.50 MiB  
withoutcollections 40.00 KiB

[direct: mongos] test\> use collection1  
switched to db collection1  
[direct: mongos] collection1\> show collections

[direct: mongos] collection1\>

I could see collection1 db size is 72.00 KiB even I couldn’t see any collections under collection1 and this is the expected behaviour of logical backup.

If I know the collection name created under collection1 db, I will bring back the removed collection again using the command - **db.createCollection(“collection1”)**

and if I don’t want, I will delete the collection permanently the same way using the command **db.dropCollection()** or **db.dropDatabase()** after bring back the removed collection.

**what if I don’t know the collection name, how I will bring back the removed collection and how I will delete the removed collection permanently ?**
