<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
	<channel>
		<title>Аспро: ЛайтШоп [тема: Получить все снимки виртуальных машин.]</title>
		<link>http://proxmox.su</link>
		<description>Новое в теме Получить все снимки виртуальных машин. форума Proxmox Виртуальная Среда на сайте Аспро: ЛайтШоп [proxmox.su]</description>
		<language>ru</language>
		<docs>http://backend.userland.com/rss2</docs>
		<pubDate>Tue, 24 Nov 2026 08:04:26 +0300</pubDate>
		<item>
			<title>Получить все снимки виртуальных машин.</title>
			<description><![CDATA[<b><a href="http://proxmox.su/forum/messages/forum63/message314548/76319-poluchit-vse-snimki-virtualnykh-mashin.">Получить все снимки виртуальных машин.</a></b> <i>Proxmox Виртуальная Среда</i> в форуме <a href="http://proxmox.su/forum/forum63/">Proxmox Виртуальная Среда</a>. <br />
			Спасибо за помощь. Локаль уже en_US.UTF-8. Не знаю, откуда взялись эти обратные кавычки! PVE 8.3.3 (на Debian 12.9) <br />
			<i>16.02.2025 09:30:00, BeWog.</i>]]></description>
			<link>http://proxmox.su/forum/messages/forum63/message314548/76319-poluchit-vse-snimki-virtualnykh-mashin.</link>
			<guid>http://proxmox.su/forum/messages/forum63/message314548/76319-poluchit-vse-snimki-virtualnykh-mashin.</guid>
			<pubDate>Sun, 16 Feb 2025 09:30:00 +0300</pubDate>
			<category>Proxmox Виртуальная Среда</category>
		</item>
		<item>
			<title>Получить все снимки виртуальных машин.</title>
			<description><![CDATA[<b><a href="http://proxmox.su/forum/messages/forum63/message314547/76319-poluchit-vse-snimki-virtualnykh-mashin.">Получить все снимки виртуальных машин.</a></b> <i>Proxmox Виртуальная Среда</i> в форуме <a href="http://proxmox.su/forum/forum63/">Proxmox Виртуальная Среда</a>. <br />
			Привет @BeWog, спасибо за обратную связь, тебе повезло, я уже переписал скрипт с нуля, так как в нём были проблемы. Может быть, это тоже исправит твою проблему, но я не могу протестировать, так как не говорю по-французски. Кстати, я бы рекомендовал запускать Proxmox на английской версии Linux, потому что у многих скриптов возникают проблемы с разными языками, и в худшем случае это может даже привести к простоям, если фрагмент кода Proxmox не переведён правильно и вызывает ошибку.<br /><br />Примечание: для работы скрипта требуется установленный `jq`, иначе вывод не будет отформатирован.<br /><br />Bash: #!/bin/bash<br /><br />vms_array=""<br />cts_array=""<br /><br /># ---------- VMs ----------<br />readarray -t vm_ids &lt; &lt;(qm list | awk 'NR&gt;1 {print $1}')<br /># Если виртуальных машин нет, vm_ids будет пустым<br /><br /># Собираем все снимки для каждого ID виртуальной машины<br />vm_json_parts=() &nbsp;# Здесь храним подмассивы (если у ВМ есть снимки)<br /><br />for vm in "${vm_ids[@]}"; do<br /> &nbsp;[[ -z "$vm" ]] && continue<br /> &nbsp;snapshot_list=$(qm listsnapshot "$vm" | grep -v "current" | awk '{$1=""; print $0}' | sed 's/^ *//')<br /><br /> &nbsp;# Если снимков нет, пропускаем<br /> &nbsp;[[ -z "$snapshot_list" ]] && continue<br /><br /> &nbsp;# Строим массив JSON для этой виртуальной машины, где каждый элемент — объект JSON, представляющий снимок.<br /> &nbsp;this_vm_snapshots="["<br /><br /> &nbsp;# Парсим построчно<br /> &nbsp;first_line=true<br /> &nbsp;while read -r line; do<br /> &nbsp; &nbsp;[[ -z "$line" ]] && continue<br /> &nbsp; &nbsp;# line обычно содержит: &lt;имя_снимка&gt; &lt;ГГГГ-ММ-ДД&gt; &lt;ЧЧ:ММ:СС&gt; &lt;описание...&gt;<br /> &nbsp; &nbsp;# Разделяем:<br /> &nbsp; &nbsp;name=$(awk '{print $1}' &lt;&lt;&lt; "$line" | sed 's/-&gt;//g')<br /> &nbsp; &nbsp;date=$(awk '{print $2}' &lt;&lt;&lt; "$line")<br /> &nbsp; &nbsp;time=$(awk '{print $3}' &lt;&lt;&lt; "$line")<br /> &nbsp; &nbsp;desc=$(awk '{$1=""; $2=""; $3=""; print $0}' &lt;&lt;&lt; "$line" | xargs)<br /><br /> &nbsp; &nbsp;[[ -z "$desc" ]] && desc="no-description"<br /> &nbsp; &nbsp;timestamp="$date $time"<br /><br /> &nbsp; &nbsp;# Первая запись -&gt; нет запятой, после неё всегда добавляем запятую<br /> &nbsp; &nbsp;if $first_line; then<br /> &nbsp; &nbsp; &nbsp;first_line=false<br /> &nbsp; &nbsp;else<br /> &nbsp; &nbsp; &nbsp;this_vm_snapshots+=","<br /> &nbsp; &nbsp;fi<br /><br /> &nbsp; &nbsp;# Преобразуем в объекты JSON<br /> &nbsp; &nbsp;this_vm_snapshots+="{\"vmid\":\"$vm\",\"name\":\"$name\",\"timestamp\":\"$timestamp\",\"description\":\"$desc\"}"<br /> &nbsp;done &lt;&lt;&lt; "$snapshot_list"<br /><br /> &nbsp;this_vm_snapshots+="]" &nbsp;# Закрываем массив<br /><br /> &nbsp;# Добавляем этот блок массива к vms_array<br /> &nbsp;vm_json_parts+=( "$this_vm_snapshots" )<br />done<br /><br /># Теперь собираем vm_json_parts в массив JSON<br /># (Каждый элемент vm_json_parts — это уже массив, например, "[ {...}, {...} ]")<br />if ((${#vm_json_parts[@]} == 0)); then<br /> &nbsp;# Снимков не найдено -&gt; пустой массив<br /> &nbsp;vms_array="[]"<br />else<br /> &nbsp;# Объединяем с запятыми<br /> &nbsp;vms_array="["<br /> &nbsp;for (( i=0; i&lt;${#vm_json_parts[@]}; i++ )); do<br /> &nbsp; &nbsp;[[ $i -gt 0 ]] && vms_array+=","<br /> &nbsp; &nbsp;vms_array+="${vm_json_parts[$i]}"<br /> &nbsp;done<br /> &nbsp;vms_array+="]"<br />fi<br /><br /># ---------- Containers ----------<br />readarray -t ct_ids &lt; &lt;(pct list | awk 'NR&gt;1 {print $1}')<br /><br />ct_json_parts=()<br />for ct in "${ct_ids[@]}"; do<br /> &nbsp;[[ -z "$ct" ]] && continue<br /> &nbsp;snapshot_list=$(pct listsnapshot "$ct" | grep -v "current" | awk '{$1=""; print $0}' | sed 's/^ *//')<br /><br /> &nbsp;[[ -z "$snapshot_list" ]] && continue<br /><br /> &nbsp;this_ct_snapshots="["<br /> &nbsp;first_line=true<br /> &nbsp;while read -r line; do<br /> &nbsp; &nbsp;[[ -z "$line" ]] && continue<br /> &nbsp; &nbsp;name=$(awk '{print $1}' &lt;&lt;&lt; "$line" | sed 's/-&gt;//g')<br /> &nbsp; &nbsp;date=$(awk '{print $2}' &lt;&lt;&lt; "$line")<br /> &nbsp; &nbsp;time=$(awk '{print $3}' &lt;&lt;&lt; "$line")<br /> &nbsp; &nbsp;desc=$(awk '{$1=""; $2=""; $3=""; print $0}' &lt;&lt;&lt; "$line" | xargs)<br /><br /> &nbsp; &nbsp;[[ -z "$desc" ]] && desc="no-description"<br /> &nbsp; &nbsp;timestamp="$date $time"<br /><br /> &nbsp; &nbsp;if $first_line; then<br /> &nbsp; &nbsp; &nbsp;first_line=false<br /> &nbsp; &nbsp;else<br /> &nbsp; &nbsp; &nbsp;this_ct_snapshots+=","<br /> &nbsp; &nbsp;fi<br /><br /> &nbsp; &nbsp;this_ct_snapshots+="{\"ctid\":\"$ct\",\"name\":\"$name\",\"timestamp\":\"$timestamp\",\"description\":\"$desc\"}"<br /> &nbsp;done &lt;&lt;&lt; "$snapshot_list"<br /><br /> &nbsp;this_ct_snapshots+="]"<br /> &nbsp;ct_json_parts+=( "$this_ct_snapshots" )<br />done<br /><br />if ((${#ct_json_parts[@]} == 0)); then<br /> &nbsp;cts_array="[]"<br />else<br /> &nbsp;cts_array="["<br /> &nbsp;for (( i=0; i&lt;${#ct_json_parts[@]}; i++ )); do<br /> &nbsp; &nbsp;[[ $i -gt 0 ]] && cts_array+=","<br /> &nbsp; &nbsp;cts_array+="${ct_json_parts[$i]}"<br /> &nbsp;done<br /> &nbsp;cts_array+="]"<br />fi<br /><br /># Собираем финальный JSON<br />snapshots_json="{\"vms\":$vms_array,\"containers\":$cts_array}"<br /><br />echo "$snapshots_json" | jq <br />
			<i>16.02.2025 00:30:00, Mikachu.</i>]]></description>
			<link>http://proxmox.su/forum/messages/forum63/message314547/76319-poluchit-vse-snimki-virtualnykh-mashin.</link>
			<guid>http://proxmox.su/forum/messages/forum63/message314547/76319-poluchit-vse-snimki-virtualnykh-mashin.</guid>
			<pubDate>Sun, 16 Feb 2025 00:30:00 +0300</pubDate>
			<category>Proxmox Виртуальная Среда</category>
		</item>
		<item>
			<title>Получить все снимки виртуальных машин.</title>
			<description><![CDATA[<b><a href="http://proxmox.su/forum/messages/forum63/message314546/76319-poluchit-vse-snimki-virtualnykh-mashin.">Получить все снимки виртуальных машин.</a></b> <i>Proxmox Виртуальная Среда</i> в форуме <a href="http://proxmox.su/forum/forum63/">Proxmox Виртуальная Среда</a>. <br />
			У меня не получается получить одинаковый результат с командой qm listsnapshot.<br /><br />Bash: root@pve-01:~# qm listsnapshot 100<br />`-&gt; snap_clean 2025-02-12 09:08:01 Installation<br />`-&gt; courant Вы здесь! Эти обратные кавычки усложняют отображение!<br />Bash: # qm listsnapshot 100 | grep -v "current"<br />grep: (standard input): binary file matches <br />
			<i>15.02.2025 15:34:00, BeWog.</i>]]></description>
			<link>http://proxmox.su/forum/messages/forum63/message314546/76319-poluchit-vse-snimki-virtualnykh-mashin.</link>
			<guid>http://proxmox.su/forum/messages/forum63/message314546/76319-poluchit-vse-snimki-virtualnykh-mashin.</guid>
			<pubDate>Sat, 15 Feb 2025 15:34:00 +0300</pubDate>
			<category>Proxmox Виртуальная Среда</category>
		</item>
		<item>
			<title>Получить все снимки виртуальных машин.</title>
			<description><![CDATA[<b><a href="http://proxmox.su/forum/messages/forum63/message314545/76319-poluchit-vse-snimki-virtualnykh-mashin.">Получить все снимки виртуальных машин.</a></b> <i>Proxmox Виртуальная Среда</i> в форуме <a href="http://proxmox.su/forum/forum63/">Proxmox Виртуальная Среда</a>. <br />
			Привет! Я наткнулся на эту проблему и написал простой скрипт, который перечисляет все снапшоты в формате JSON (он также создаёт файл snapshot.json). Пожалуйста, всегда проверяй и тестируй скрипты, прежде чем их запускать. Я не несу ответственности, если что-то пойдёт не так (хотя ничего не должно случиться, он просто переcчитывает их). Использует команды pct listsnapshot &lt;LXCID&gt; и qm listsnapshot &lt;VMID&gt;.<br /><br />* &nbsp; Перечисляет все снапшоты для обеих ВМ и контейнеров.<br />* &nbsp; Исключает "current" снапшоты (это не настоящие снапшоты — это "Ты здесь").<br />* &nbsp; Извлекает имя снапшота, метку времени и описание.<br />* &nbsp; Форматирует вывод в чистый JSON для удобства разбора.<br /><br />Просто сохрани скрипт как list_snapshots в твоем узле Proxmox и запусти его с помощью bash list_snapshots. Если хочешь, можешь поместить его в /bin, чтобы не пришлось каждый раз указывать путь к файлу. Хотя я не уверен, что это сломает что-нибудь при обновлении.<br /><br />`#!/bin/bash`<br /><br /># Инициализируем JSON объект<br />echo "{ \"vms\": [" &gt; snapshots.json<br /><br /># Получаем снапшоты ВМ<br />first_vm=true<br />for vm in $(qm list | awk 'NR&gt;1 {print $1}'); do<br /> &nbsp; &nbsp;snapshot_list=$(qm listsnapshot $vm | grep -v "current" | awk '{$1=""; print $0}' | sed 's/^ *//')<br /><br /> &nbsp; &nbsp;if [[ ! -z "$snapshot_list" ]]; then<br /> &nbsp; &nbsp; &nbsp; &nbsp;if [ "$first_vm" = false ]; then<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;echo "," &gt;&gt; snapshots.json<br /> &nbsp; &nbsp; &nbsp; &nbsp;fi<br /> &nbsp; &nbsp; &nbsp; &nbsp;first_vm=false<br /> &nbsp; &nbsp; &nbsp; &nbsp;echo "[" &gt;&gt; snapshots.json<br /><br /> &nbsp; &nbsp; &nbsp; &nbsp;while read -r name date time desc; do<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;name=$(echo "$name" | sed 's/`-&gt;//g' | xargs) &nbsp;# Удаляем маркер в начале и убираем лишние пробелы<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;timestamp="$date $time"<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;description=$(echo "$desc" | xargs) &nbsp;# Убираем лишние пробелы<br /><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# Обрабатываем случай, когда описание отсутствует<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if [[ -z "$description" ]]; then<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;description="no-description"<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fi<br /><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;echo " &nbsp;{ \"vmid\": \"$vm\", \"name\": \"$name\", \"timestamp\": \"$timestamp\", \"description\": \"$description\" }," &gt;&gt; snapshots.json<br /> &nbsp; &nbsp; &nbsp; &nbsp;done &lt;&lt;&lt; "$snapshot_list"<br /><br /> &nbsp; &nbsp; &nbsp; &nbsp;# Удаляем последнюю запятую и закрываем JSON массив<br /> &nbsp; &nbsp; &nbsp; &nbsp;sed -i '$ s/,$//' snapshots.json<br /> &nbsp; &nbsp; &nbsp; &nbsp;echo "]" &gt;&gt; snapshots.json<br /> &nbsp; &nbsp;fi<br />done<br /><br />echo "], \"containers\": [" &gt;&gt; snapshots.json<br /><br /># Получаем снапшоты контейнеров<br />first_ct=true<br />for ct in $(pct list | awk 'NR&gt;1 {print $1}'); do<br /> &nbsp; &nbsp;snapshot_list=$(pct listsnapshot $ct | grep -v "current" | awk '{$1=""; print $0}' | sed 's/^ *//')<br /><br /> &nbsp; &nbsp;if [[ ! -z "$snapshot_list" ]]; then<br /> &nbsp; &nbsp; &nbsp; &nbsp;if [ "$first_ct" = false ]; then<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;echo "," &gt;&gt; snapshots.json<br /> &nbsp; &nbsp; &nbsp; &nbsp;fi<br /> &nbsp; &nbsp; &nbsp; &nbsp;first_ct=false<br /> &nbsp; &nbsp; &nbsp; &nbsp;echo "[" &gt;&gt; snapshots.json<br /><br /> &nbsp; &nbsp; &nbsp; &nbsp;while read -r name date time desc; do<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;name=$(echo "$name" | sed 's/`-&gt;//g' | xargs) &nbsp;# Удаляем маркер в начале и убираем лишние пробелы<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;timestamp="$date $time"<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;description=$(echo "$desc" | xargs) &nbsp;# Убираем лишние пробелы<br /><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# Обрабатываем случай, когда описание отсутствует<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if [[ -z "$description" ]]; then<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;description="no-description"<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fi<br /><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;echo " &nbsp;{ \"ctid\": \"$ct\", \"name\": \"$name\", \"timestamp\": \"$timestamp\", \"description\": \"$description\" }," &gt;&gt; snapshots.json<br /> &nbsp; &nbsp; &nbsp; &nbsp;done &lt;&lt;&lt; "$snapshot_list"<br /><br /> &nbsp; &nbsp; &nbsp; &nbsp;# Удаляем последнюю запятую и закрываем JSON массив<br /> &nbsp; &nbsp; &nbsp; &nbsp;sed -i '$ s/,$//' snapshots.json<br /> &nbsp; &nbsp; &nbsp; &nbsp;echo "]" &gt;&gt; snapshots.json<br /> &nbsp; &nbsp;fi<br />done<br /><br />echo "] }" &gt;&gt; snapshots.json<br /><br /># Выводим JSON<br />cat snapshots.json<br /><br />Ожидаемый вывод: JSON: {<br /> &nbsp;"vms": [<br /> &nbsp; &nbsp;[<br /> &nbsp; &nbsp; &nbsp;{ "vmid": "112", "name": "goti", "timestamp": "2024-05-17 21:27:03", "description": "no-description" }<br /> &nbsp; &nbsp;],<br /> &nbsp; &nbsp;[<br /> &nbsp; &nbsp; &nbsp;{ "vmid": "131", "name": "ansible_test", "timestamp": "2024-11-04 12:32:39", "description": "no-description" }<br /> &nbsp; &nbsp;],<br /> &nbsp; &nbsp;[<br /> &nbsp; &nbsp; &nbsp;{ "vmid": "530", "name": "totally_legit_snapshot_name", "timestamp": "2025-01-17 14:29:16", "description": "no-description" }<br /> &nbsp; &nbsp;]<br /> &nbsp;],<br /> &nbsp;"containers": [<br /> &nbsp; &nbsp;[<br /> &nbsp; &nbsp; &nbsp;{ "ctid": "135", "name": "update", "timestamp": "2024-11-30 12:15:26", "description": "no-description" }<br /> &nbsp; &nbsp;]<br /> &nbsp;]<br />} <br />
			<i>02.02.2025 12:53:00, Mikachu.</i>]]></description>
			<link>http://proxmox.su/forum/messages/forum63/message314545/76319-poluchit-vse-snimki-virtualnykh-mashin.</link>
			<guid>http://proxmox.su/forum/messages/forum63/message314545/76319-poluchit-vse-snimki-virtualnykh-mashin.</guid>
			<pubDate>Sun, 02 Feb 2025 12:53:00 +0300</pubDate>
			<category>Proxmox Виртуальная Среда</category>
		</item>
		<item>
			<title>Получить все снимки виртуальных машин.</title>
			<description><![CDATA[<b><a href="http://proxmox.su/forum/messages/forum63/message314544/76319-poluchit-vse-snimki-virtualnykh-mashin.">Получить все снимки виртуальных машин.</a></b> <i>Proxmox Виртуальная Среда</i> в форуме <a href="http://proxmox.su/forum/forum63/">Proxmox Виртуальная Среда</a>. <br />
			Если это не видно сразу, возможно, придется перебирать все узлы через API. <br />
			<i>09.08.2024 18:30:00, LnxBil.</i>]]></description>
			<link>http://proxmox.su/forum/messages/forum63/message314544/76319-poluchit-vse-snimki-virtualnykh-mashin.</link>
			<guid>http://proxmox.su/forum/messages/forum63/message314544/76319-poluchit-vse-snimki-virtualnykh-mashin.</guid>
			<pubDate>Fri, 09 Aug 2024 18:30:00 +0300</pubDate>
			<category>Proxmox Виртуальная Среда</category>
		</item>
		<item>
			<title>Получить все снимки виртуальных машин.</title>
			<description><![CDATA[<b><a href="http://proxmox.su/forum/messages/forum63/message314543/76319-poluchit-vse-snimki-virtualnykh-mashin.">Получить все снимки виртуальных машин.</a></b> <i>Proxmox Виртуальная Среда</i> в форуме <a href="http://proxmox.su/forum/forum63/">Proxmox Виртуальная Среда</a>. <br />
			Было бы интересно получать эту информацию из API, но перечислять все серверы… <br />
			<i>09.08.2024 16:52:00, damo2929.</i>]]></description>
			<link>http://proxmox.su/forum/messages/forum63/message314543/76319-poluchit-vse-snimki-virtualnykh-mashin.</link>
			<guid>http://proxmox.su/forum/messages/forum63/message314543/76319-poluchit-vse-snimki-virtualnykh-mashin.</guid>
			<pubDate>Fri, 09 Aug 2024 16:52:00 +0300</pubDate>
			<category>Proxmox Виртуальная Среда</category>
		</item>
		<item>
			<title>Получить все снимки виртуальных машин.</title>
			<description><![CDATA[<b><a href="http://proxmox.su/forum/messages/forum63/message314542/76319-poluchit-vse-snimki-virtualnykh-mashin.">Получить все снимки виртуальных машин.</a></b> <i>Proxmox Виртуальная Среда</i> в форуме <a href="http://proxmox.su/forum/forum63/">Proxmox Виртуальная Среда</a>. <br />
			Привет! Как получить все снапшоты для виртуальной машины? Когда я делаю снапшот через UI, создаётся новый диск, но при использовании команды Code: qm snapshot &lt;vmID&gt; я не вижу нового диска. Не мог бы кто-нибудь помочь? Спасибо. <br />
			<i>24.03.2021 11:28:00, oguz.</i>]]></description>
			<link>http://proxmox.su/forum/messages/forum63/message314542/76319-poluchit-vse-snimki-virtualnykh-mashin.</link>
			<guid>http://proxmox.su/forum/messages/forum63/message314542/76319-poluchit-vse-snimki-virtualnykh-mashin.</guid>
			<pubDate>Wed, 24 Mar 2021 11:28:00 +0300</pubDate>
			<category>Proxmox Виртуальная Среда</category>
		</item>
	</channel>
</rss>
