Clone snapshot via CLI

Hey there.
Can anyone show me an example of cloning snapshots via Truenas CLI
There is no documentation about this.

Just out of interest, why do you want that?

I mean, you can do it from the GUI or from the shell. Mb it’s possible via CLI; I’m just not familiar with it.

my boss want to do this with scripts. NO GUI :rofl:

I do believe a standard zfs clone in the shell would work for this case.

1 Like

i think it will work.
But TruenasCLI contains that option. I just can’t find the right syntax

1 Like

Or you can use a python script with our API client (already installed on TrueNAS) to use our API: pool.snapshot.clone — TrueNAS API v26.04.0 documentation

This has the advantage that your script will be portable to any system with the API client installed (just provide API key and hostname / IP address of the TrueNAS server instead of using the default AF_UNIX connection).

If you’re running the script locally on the NAS you can do something like:

from truenas_api_client import Client

with Client() as c:
    c.call('smb.config')

For example. The above authenticates to the middleware as your currently-authenticated user.

1 Like

I found a solution in create dataset command documentation
so my example is:
storage snapshot clone snapshot_clone={“snapshot”:“NAS/debiscsi@123”,“dataset_dst”:“NAS/123”}

1 Like