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

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

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.

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?

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.

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

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 ?