Here is command and example php
btrfs subvolume snapshot '.$readonly.' '.escapeshellarg($subvol).' '.escapeshellarg($snapshoty).
subvol is path to snap.
snapshoty is the name of the snapshot.
readonly is -r if you want the snapshot to be readonly.
case 'create_snapshot':
$snapshot = urldecode(($_POST['snapshot']));
$subvol = urldecode(($_POST['subvol']));
$readonly = urldecode(($_POST['readonly']));
if ($readonly == "true") $readonly = "-r" ; else $readonly="" ;
$DateTimeF = findText("{", "}", $snapshot) ;
if ($DateTimeF == "YMD") $DateTime = "YmdHis" ; else $DateTime = $DateTimeF ;
$ymd = date($DateTime, time());
$snapshoty = str_replace("{".$DateTimeF."}", $ymd, $snapshot);
# check_to_dir($snapshoty) ;
$slashpos = substr(strrchr($snapshot,'/'), 1);
$directory = substr($snapshot, 0, - strlen($slashpos));
if (!is_dir($directory) && $snapshot != $subvol) mkdir($directory, 0777, true) ;
$result = NULL ;
exec('btrfs subvolume snapshot '.$readonly.' '.escapeshellarg($subvol).' '.escapeshellarg($snapshoty)." 2>&1", $result, $error) ;
snap_manager_log('btrfs snapshot create '.$snapshot.' '.$error.' '.$result[0]) ;
if ($error=="1") $error_rtn = false ; else $error_rtn=true ;
echo json_encode(array("success"=>$error_rtn, "error"=>$result));
break;
Auto script.
https://github.com/SimonFair/Snapshots/blob/b4ff445c44f3618a74d2737873c3efadfda43a38/source/include/snapping.php#L228