# If I delete the data directory, How should I recover?

**URL:** <https://forums.percona.com/t/if-i-delete-the-data-directory-how-should-i-recover/35618>\
**Category:** Percona Backup for MongoDB\
**Created:** [December 12, 2024, 2:39am UTC](https://forums.percona.com/t/if-i-delete-the-data-directory-how-should-i-recover/35618 "2024-12-12T02:39:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dogs\_Cute](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/dogs_cute/32/12754_2.png) [@dogs\_Cute](https://forums.percona.com/u/dogs_Cute)\
**Post date:** [December 12, 2024, 2:39am UTC](https://forums.percona.com/t/if-i-delete-the-data-directory-how-should-i-recover/35618/1 "2024-12-12T02:39:57Z")

</div>

I have a replica set, I made a physical backup, then I stopped the database service and deleted the files in the data directory. I started the data again, initialized the replication set and pbm users, then configured the pbm parameter file and started the agent. But pbm list has no results. I know this information is stored under admin. So how should I restore the database?

---

<div class="post-metadata">

**Author:** ![Ivan\_Groenewold](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/ivan_groenewold/32/6299_2.png) [@Ivan\_Groenewold](https://forums.percona.com/u/Ivan_Groenewold)\
**Post date:** [December 12, 2024, 1:38pm UTC](https://forums.percona.com/t/if-i-delete-the-data-directory-how-should-i-recover/35618/2 "2024-12-12T13:38:55Z")

</div>

Hi, you have to run pbm with --force-resync so that it reads your backups from the storage. After that you will be able to restore.

---

<div class="post-metadata">

**Author:** ![dogs\_Cute](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/dogs_cute/32/12754_2.png) [@dogs\_Cute](https://forums.percona.com/u/dogs_Cute)\
**Post date:** [December 12, 2024, 1:45pm UTC](https://forums.percona.com/t/if-i-delete-the-data-directory-how-should-i-recover/35618/3 "2024-12-12T13:45:15Z")

</div>

but, no --force-resync .

```auto
[root@mongodb01 backup]# pbm version
Version: 2.7.0
Platform: linux/amd64
GitCommit: 957ac501f939b1b784fcdcf61dcc5b9bf171e0b9
GitBranch: release-2.7.0
BuildTime: 2024-10-02_12:55_UTC
GoVersion: go1.22.8

```

```auto

[root@mongodb01 backup]# pbm restore --help
usage: pbm restore [<flags>] [<backup_name>]

Restore backup

Flags:
  -h, --help Show context-sensitive help (also try --help-long and --help-man).
      --mongodb-uri=MONGODB-URI MongoDB connection string (Default = PBM_MONGODB_URI environment variable)
  -o, --out=text Output format <text>/<json>
      --time=TIME Restore to the point-in-time. Set in format 2006-01-02T15:04:05
      --base-snapshot=BASE-SNAPSHOT
                                 Override setting: Name of older snapshot that PITR will be based on during restore.
      --num-parallel-collections=NUM-PARALLEL-COLLECTIONS
                                 Number of parallel collections
      --ns=NS Namespaces to restore (e.g. "db1.*,db2.collection2"). If not set, restore all ("*.*")
      --with-users-and-roles Includes users and roles for selected database (--ns flag)
  -w, --wait Wait for the restore to finish.
      --wait-time=WAIT-TIME Maximum wait time
  -x, --external External restore.
  -c, --config=CONFIG Mongod config for the source data. External backups only!
      --ts=TS MongoDB cluster time to restore to. In <T,I> format (e.g. 1682093090,9). External backups only!
      --replset-remapping=REPLSET-REMAPPING
                                 re-map replset names for backups/oplog (e.g. to_name_1=from_name_1,to_name_2=from_name_2)

Args:
  [<backup_name>] Backup name to restore

```

---

<div class="post-metadata">

**Author:** ![Ivan\_Groenewold](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/ivan_groenewold/32/6299_2.png) [@Ivan\_Groenewold](https://forums.percona.com/u/Ivan_Groenewold)\
**Post date:** [December 12, 2024, 1:50pm UTC](https://forums.percona.com/t/if-i-delete-the-data-directory-how-should-i-recover/35618/4 "2024-12-12T13:50:10Z")

</div>

Try ` pbm config --force-resync`
