Cloning an Instance with CLI
You can run duplicates of a snapshotted process using the mvmcli snapshot restore --clone command.
Before you begin
About this task
To clone a snapshot, Memory Machine creates a new PID namespace. The snapshot to be cloned is then run in the new PID namespace, with the original PID. In this way:
- The OS can see the cloned process in the original namespace (though with a new PID)
- The cloned process is identical to the snapshot and has the same PID (though running in a subordinate namespace)
- Any number of processes can be cloned from a single snapshot and run in their own PID namespaces as described above
Procedure
To clone an instance, type the following:
# mvmcli snapshot restore -l|--label label -c|--clone -d|--detached
where:
- label
- is the label of the snapshot to restore.
- -c or --clone
-
causes the restored process to clone the instance by restoring the snapshot to its original PID in a different PID namespace.
- -d or --detached
- causes the restored process to detach from the command-line shell. Default is to not detach, so that the terminal shell is owned by the restored application.
Results
A new process is created, running the snapshot in a subordinate PID namespace as described above. For example:
# mvmcli snapshot restore -l redis_player_1_ae204956 -c -d Restore finished. Process detached. Resuming tasks # # mvmcli snapshot list -n redis-server PID User Date Started Command ------------------------------------------------------------------- 18074 root Tue Aug 25 15:39:13 2020 /root/redis-5.0.7/src/redis-server *:9001 Clone: PID 27424 Snapshots: None ------------------------------------------------------------------- 18074 root Mon Aug 17 22:52:53 2020 /root/redis-5.0.7/src/redis-server *:9001 Snapshots: Date Created Status Label Tue Aug 18 12:39:18 2020 Persisted redis_player_1_ae204956 ------------------------------------------------------------------- 18074 root Tue Aug 25 15:40:22 2020 /root/redis-5.0.7/src/redis-server *:9001