{"id":1928,"date":"2023-07-01T13:52:54","date_gmt":"2023-07-01T11:52:54","guid":{"rendered":"https:\/\/hannes.enjoys.it\/blog\/?p=1928"},"modified":"2026-03-20T20:54:11","modified_gmt":"2026-03-20T19:54:11","slug":"backing-up-hetzner-snapshots-locally","status":"publish","type":"post","link":"https:\/\/hannes.enjoys.it\/blog\/2023\/07\/backing-up-hetzner-snapshots-locally\/","title":{"rendered":"Backing up Hetzner snapshots locally"},"content":{"rendered":"\n<p>Hetzner is a nice, cheap host for server. Unfortunately they do not let you download backups and snapshots of cloud servers <em>locally<\/em>. So you are kind of locked in with them.<\/p>\n\n\n\n<p>Here is how I create full disk backups for e.g. standard CX11 servers with default images.<\/p>\n\n\n\n<p>Make sure you understand everything before you attempt this. Pay special attention to your own partitions and make sure you archive what you really need. Consider imaging the whole device instead of just a partition.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Create a backup<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Create a new snapshot of your server<\/li>\n\n\n\n<li>Create a new server from it<\/li>\n\n\n\n<li>Boot said server in rescue mode<\/li>\n\n\n\n<li>Use good old <code>dd<\/code> and <code>gzip<\/code> to image the main disk to a local archive<\/li>\n\n\n\n<li><code>ssh root@SERVERIP \"dd if=\/dev\/sda1 bs=1M status=progress | gzip -\" | dd of=SERVERIP.sda1.dd.gz bs=1M<\/code>\n<ul class=\"wp-block-list\">\n<li>The <code>bs=1M<\/code> is fairly random by me, worked well, didn&#8217;t care to optimize<\/li>\n\n\n\n<li><code>gzip<\/code> (with the default compression level) kind of maxed out the server CPU but still enabled me to almost max out my download bandwidth. Of course the ratio between remote CPU compression speed vs download bandwidth depends on your specific situation. You might want to use <code>xz<\/code> or <code>zstd<\/code> instead.<\/li>\n\n\n\n<li>Consider nulling everything but the files first, i.e. mount your partition and <code>dd if=\/dev\/zero of=zeros bs=4M status=progress<\/code> on it.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Don&#8217;t be stupid, do it twice and compare the checksums<\/strong><\/li>\n<\/ul>\n\n\n\n<p>If you do not need your server to be live during backup, you can skip the snapshotting and second server of course, just boot your server in rescue mode instead.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Build a new server from a backup<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Create a new server using the same or a similar configuration as the backed up one<\/li>\n\n\n\n<li>Boot said server in rescue mode<\/li>\n\n\n\n<li><code>cat SERVERIP.sda1.dd.gz | ssh root@SERVERIP \"gunzip -c | dd of=\/dev\/sda1 bs=1M status=progress conv=fsync\"<\/code><\/li>\n\n\n\n<li>Reboot to leave rescue mode<\/li>\n<\/ul>\n\n\n\n<p>If you want to restore your server because of a breakage, just boot it into rescue mode and do the same as above otherwise.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hetzner is a nice, cheap host for server. Unfortunately they do not let you download backups and snapshots of cloud servers locally. So you are kind of locked in with them. Here is how I create full disk backups for e.g. standard CX11 servers with default images. Make sure you understand everything before you attempt [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,40],"tags":[],"class_list":["post-1928","post","type-post","status-publish","format-standard","hentry","category-linux","category-small-things"],"_links":{"self":[{"href":"https:\/\/hannes.enjoys.it\/blog\/wp-json\/wp\/v2\/posts\/1928","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hannes.enjoys.it\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hannes.enjoys.it\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hannes.enjoys.it\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hannes.enjoys.it\/blog\/wp-json\/wp\/v2\/comments?post=1928"}],"version-history":[{"count":4,"href":"https:\/\/hannes.enjoys.it\/blog\/wp-json\/wp\/v2\/posts\/1928\/revisions"}],"predecessor-version":[{"id":2083,"href":"https:\/\/hannes.enjoys.it\/blog\/wp-json\/wp\/v2\/posts\/1928\/revisions\/2083"}],"wp:attachment":[{"href":"https:\/\/hannes.enjoys.it\/blog\/wp-json\/wp\/v2\/media?parent=1928"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hannes.enjoys.it\/blog\/wp-json\/wp\/v2\/categories?post=1928"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hannes.enjoys.it\/blog\/wp-json\/wp\/v2\/tags?post=1928"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}