{"id":2284,"date":"2023-12-04T17:09:32","date_gmt":"2023-12-04T22:09:32","guid":{"rendered":"https:\/\/www.wildow.com\/blog\/?p=2284"},"modified":"2023-12-04T17:09:32","modified_gmt":"2023-12-04T22:09:32","slug":"proxmox-config-backups","status":"publish","type":"post","link":"http:\/\/www.wildow.com\/blog\/?p=2284","title":{"rendered":"ProxMox Config Backups"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\" id=\"page-title\">ProxMox Config Backups<\/h1>\n\n\n\n<p>Submitted by&nbsp;dziemecki&nbsp;on Sun, 02\/08\/2015 &#8211; 13:50<\/p>\n\n\n\n<p>I recently set up a&nbsp;<a href=\"https:\/\/web.archive.org\/web\/20220604212935\/https:\/\/www.proxmox.com\/\">ProxMox<\/a>&nbsp;virtual host and was quite impressed with the features one can get in an open source virtualization tool. The&nbsp;<a href=\"https:\/\/web.archive.org\/web\/20220604212935\/https:\/\/www.proxmox.com\/proxmox-ve\/features\">feature list<\/a>&nbsp;for ProxMox is long and impressive, but one thing oddly missing is a way to back up its own configuration. For those long versed in the ways of Linux administration, the solution is probably obvious, but in case it isn&#8217;t, here&#8217;s one way to do it.<\/p>\n\n\n\n<p>Like just about every other Linux app in existence, most configuration is stored in the &#8220;\/etc&#8221; sub-directory. My approach was to basically to archive that, and dump it to a mounted share on another server. And set up a cron job to do it without me having to worry about it.<\/p>\n\n\n\n<p>To start off, create a text file where ever it makes sense for you and add this to it:# set vars _now=$(date +%Y-%m-%d.%H.%M.%S) # temporary storage directory _tdir=&#8221;\/var\/tmp&#8221; # permanent backups directory _bdir=&#8221;\/mnt\/backups\/proxmox\/config&#8221;<\/p>\n\n\n\n<p>This is just setting the table, creating a time stamp and setting local and remote directories for the process. You&#8217;ll set the directories to what works for you.<\/p>\n\n\n\n<p>Next, stop the services and give them a moment to finish:# stop host services \/etc\/init.d\/pve-cluster stop \/etc\/init.d\/pvedaemon stop \/etc\/init.d\/vz stop \/etc\/init.d\/qemu-server stop # give them a moment to finish sleep 10s<\/p>\n\n\n\n<p>The meat of the script comes next, where the key folders are archived:# copy key system files _filename1=&#8221;$_tdir\/proxmoxetc.$_now.tar&#8221; _filename2=&#8221;$_tdir\/proxmoxpve.$_now.tar&#8221; _filename3=&#8221;$_tdir\/proxmoxconfig.$_now.tar&#8221; tar -cvf &#8220;$_filename1&#8221; \/etc\/* tar -cvf &#8220;$_filename2&#8221; \/var\/lib\/pve-cluster\/*<\/p>\n\n\n\n<p>Now, restart everything before you start the file moves:# restart services \/etc\/init.d\/qemu-server start \/etc\/init.d\/vz start \/etc\/init.d\/pvedaemon start \/etc\/init.d\/pve-cluster start # qm startall &#8211; if they don&#8217;t start otherwise<\/p>\n\n\n\n<p>Finally, tar up the results, clean up the leftovers, and move everything to your backups folder.# archive the moved system file tar cvf &#8220;$_filename3&#8221; $_tdir\/*.tar &amp;&amp; rm &#8220;$_filename1&#8221; &amp;&amp; rm &#8220;$_filename2&#8221; gzip &#8220;$_filename3&#8221; # Move config archive to backup folder mv &#8220;$_filename3.gz&#8221; &#8220;$_bdir\/proxmoxconfig.$_now.tar.gz&#8221;<\/p>\n\n\n\n<p>And that&#8217;s the whole script. I dropped mine in the home folder and kicked it off in crontab with:sh \/home\/pmconfigbak<\/p>\n\n\n\n<p>On my machine, you end up with a GZipped file of about 2 megs with a name like &#8220;proxmoxconfig.2015-01-04.23.59.01.tar.gz&#8221;. Depending upon how you schedule it and the size of your server, that could eventually become a space issue so don&#8217;t forget to set up some kind of archive maintenance.<\/p>\n\n\n\n<p>To restore, move the file back to proxmox with cp, scp, webmin, a thumb drive, whatever. I place it back into the \/var\/tmp directory from whence it came. To unpack:# Unpack the original backup tar -zxvf proxmoxconfig.2015-01-02.14.38.08.tar.gz # unpack the tared contents tar -xvf proxmoxpve.2015-01-02.14.38.08.tar tar -xvf proxmoxetc.2015-01-02.14.38.08.tar<\/p>\n\n\n\n<p>If the services are running, stop them:etc\/init.d\/pve-cluster stop \/etc\/init.d\/pvedaemon stop \/etc\/init.d\/vz stop \/etc\/init.d\/qemu-server stop<\/p>\n\n\n\n<p>Copy the old content to the original directory:cp -avr \/var\/tmp\/var\/tmp\/etc \/etc cp -avr \/var\/tmp\/var\/tmp\/var \/var<\/p>\n\n\n\n<p>And, finally, restart services:\/etc\/init.d\/qemu-server start \/etc\/init.d\/vz start \/etc\/init.d\/pvedaemon start \/etc\/init.d\/pve-cluster start<\/p>\n\n\n\n<p>If nothing goes wrong, and you have separately restored the VM images using the default ProxMox process, you should be back where you started.<\/p>\n\n\n\n<p>Let&#8217;s hope it never comes to that.<\/p>\n\n\n\n<p>Tags:&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>ProxMox Config Backups Submitted by&nbsp;dziemecki&nbsp;on Sun, 02\/08\/2015 &#8211; 13:50 I recently set up a&nbsp;ProxMox&nbsp;virtual host and was quite impressed with the features one can get in an open source virtualization tool. The&nbsp;feature list&nbsp;for ProxMox is long and impressive, but one &#8230; <a class=\"more-link\" href=\"http:\/\/www.wildow.com\/blog\/?p=2284\">Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2284","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2284","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2284"}],"version-history":[{"count":1,"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2284\/revisions"}],"predecessor-version":[{"id":2285,"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2284\/revisions\/2285"}],"wp:attachment":[{"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2284"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2284"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2284"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}