{"id":2257,"date":"2012-06-19T16:11:23","date_gmt":"2012-06-19T14:11:23","guid":{"rendered":"http:\/\/blog.unelink.es\/?p=2257"},"modified":"2018-08-06T09:38:50","modified_gmt":"2018-08-06T07:38:50","slug":"backup-de-maquinas-virtuales-proxmox","status":"publish","type":"post","link":"https:\/\/hosting.airetech.es\/blog\/wiki\/backup-de-maquinas-virtuales-proxmox\/","title":{"rendered":"Backup de m\u00e1quinas virtuales Proxmox"},"content":{"rendered":"<p>El siguiente script realiza un backup de todas las m\u00e1quinas virtuales (<a href=\"https:\/\/www.unelink.es\/servidores-virtuales-33.html\" title=\"VPS\" target=\"_blank\">VPS<\/a>) que tengamos en nuestro hipervisor Proxmox.<\/p>\n<p>El modo de uso de dicho script es insertarlo en el cron para que el backup se realice peri\u00f3dicamente y, de forma adicional, se puede poner otro script al final de cada backup para que env\u00ede las copias realizadas a un servidor externo.<\/p>\n<pre>\r\n#!\/bin\/sh\r\n\r\nRUTA_DUMPS=\"\/var\/lib\/vz\/dump\/\"\r\nMAXIMO_COPIAS=5\r\n\r\nfor VZ_ID in `vzlist -1` ; do\r\n\r\n    VZ_HOSTNAME=`vzlist -o hostname -H ${VZ_ID}`\r\n    VZ_IP=`vzlist -o ip -H ${VZ_ID}`\r\n    VZ_DUMP=\"\/var\/lib\/vz\/dump\/${VZ_HOSTNAME}_\"`date '+%d%m%y%H%M%S'`\".tgz\"    \r\n\r\n    echo \"\"\r\n    echo \"vzid ${VZ_ID}\"\r\n    echo \"host ${VZ_HOSTNAME}\"\r\n    echo \"ip.ad ${VZ_IP}\"\r\n    echo \"dump ${VZ_DUMP}\"\r\n    echo \"\"\r\n\r\n    #: descartando copias viejas\r\n    TOTAL_COPIAS=`ls ${RUTA_DUMPS}${VZ_HOSTNAME}* | wc -l`\r\n    NUMERO_DESCARTADOS=`echo \"${TOTAL_COPIAS} - ${MAXIMO_COPIAS}\" | bc`\r\n    DESCARTADOS=`ls ${RUTA_DUMPS}${VZ_HOSTNAME}*  | head -n ${NUMERO_DESCARTADOS}`\r\n    for descartado in ${DESCARTADOS} ; do rm -f $descartado ; done\r\n\r\n    #: backuping\r\n    vzctl set ${VZ_ID} --ipdel all --save\r\n    cd \/var\/lib\/vz\/private\/${VZ_ID}\r\n    tar cvzf ${VZ_DUMP} .\r\n    vzctl set ${VZ_ID} --ipadd ${VZ_IP} --save\r\n\r\ndone\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"El siguiente script realiza un backup de todas las m\u00e1quinas virtuales (VPS) que tengamos en nuestro hipervisor Proxmox. El modo de uso de dicho script es insertarlo en el cron para que el backup se realice peri\u00f3dicamente y, de forma adicional, se puede poner otro script al final de cada backup para que env\u00ede las copias realizadas a un servidor&nbsp;<a href=\"https:\/\/hosting.airetech.es\/blog\/wiki\/backup-de-maquinas-virtuales-proxmox\/\" class=\"read-more\">Seguir leyendo<\/a>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[10,6],"tags":[18,216,17,214],"class_list":["post-2257","post","type-post","status-publish","format-standard","hentry","category-linux","category-wiki","tag-backup","tag-linux","tag-proxmox","tag-servidores-virtuales-vps","cat-10-id","cat-6-id"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/hosting.airetech.es\/blog\/wp-json\/wp\/v2\/posts\/2257","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hosting.airetech.es\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hosting.airetech.es\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hosting.airetech.es\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hosting.airetech.es\/blog\/wp-json\/wp\/v2\/comments?post=2257"}],"version-history":[{"count":6,"href":"https:\/\/hosting.airetech.es\/blog\/wp-json\/wp\/v2\/posts\/2257\/revisions"}],"predecessor-version":[{"id":7103,"href":"https:\/\/hosting.airetech.es\/blog\/wp-json\/wp\/v2\/posts\/2257\/revisions\/7103"}],"wp:attachment":[{"href":"https:\/\/hosting.airetech.es\/blog\/wp-json\/wp\/v2\/media?parent=2257"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hosting.airetech.es\/blog\/wp-json\/wp\/v2\/categories?post=2257"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hosting.airetech.es\/blog\/wp-json\/wp\/v2\/tags?post=2257"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}