Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Everyone,
Please could someone help me with API script to DB volume restore from the latest snapshot.
Solved! See The Solution
1 ACCEPTED SOLUTION
Drew_C has accepted the solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sure, can you try something like this to restore a volume from the latest snapshot.
# Specify the uuid of the volume
vol_uuid = 'your_volume_uuid'
snapshot_name = None # Set to None to use the latest snapshot
# Find the snapshot
snapshots = Snapshot.get_collection(vol_uuid)
latest_snapshot = None
latest_snapshot_time = 0
for snapshot in snapshots:
if latest_snapshot == None or snapshot.create_time > latest_snapshot_time:
latest_snapshot_time = snapshot.create_time
latest_snapshot = snapshot
snapshot_name = latest_snapshot.name
# Restore the volume from the snapshot
vol = Volume(uuid=vol_uuid)
vol.patch(**{'restore_to.snapshot.name': snapshot_name})
Here is a previous discussion on just restoring from a given snapshot: https://community.netapp.com/t5/ONTAP-Rest-API-Discussions/Snapshot-Restore/td-p/159284
1 REPLY 1
Drew_C has accepted the solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sure, can you try something like this to restore a volume from the latest snapshot.
# Specify the uuid of the volume
vol_uuid = 'your_volume_uuid'
snapshot_name = None # Set to None to use the latest snapshot
# Find the snapshot
snapshots = Snapshot.get_collection(vol_uuid)
latest_snapshot = None
latest_snapshot_time = 0
for snapshot in snapshots:
if latest_snapshot == None or snapshot.create_time > latest_snapshot_time:
latest_snapshot_time = snapshot.create_time
latest_snapshot = snapshot
snapshot_name = latest_snapshot.name
# Restore the volume from the snapshot
vol = Volume(uuid=vol_uuid)
vol.patch(**{'restore_to.snapshot.name': snapshot_name})
Here is a previous discussion on just restoring from a given snapshot: https://community.netapp.com/t5/ONTAP-Rest-API-Discussions/Snapshot-Restore/td-p/159284
