As explained on post how to archive a snapshot, Now to restore a snapshot from created archive, use the following sequence of commands:
lvcreate --size 1G --name mdb-new vg0
gzip -d -c snap_db-01.gz | dd of=/dev/vg0/mdb-new
mount /dev/vg0/mdb-new /srv/mongodb
The above sequence does the following:
- The lvcreate command will create a new volume this will have a maximum size of 1 gigabyte. To successfully execute this command the original file system must have a total size of 1 gigabyte. Change 1G to your desired volume size.
- It will create a new logical volume with mdb-new name, in the /dev/vg0 volume group. The path of new device will be /dev/vg0/mdb-new.
- Uncompresses and unarchives the mdb-snap01.gz into the mdb-new disk image.
- Mounts the mdb-new disk image to the /srv/mongodb directory. Modify the mount point to correspond to your MongoDB data file location, or other location as needed.
Note: The restored snapshot with above command will have a stale mongodb.lock file. You have to remove this lock file to successfully run MongoDB otherwise MongoDB may assume that the stale lock file indicates an unclean shutdown.
0 Comment(s)