{"id":267,"date":"2020-11-18T15:56:30","date_gmt":"2020-11-18T15:56:30","guid":{"rendered":"http:\/\/metajack.org\/blog\/?p=267"},"modified":"2023-07-05T15:28:09","modified_gmt":"2023-07-05T15:28:09","slug":"creating-a-simple-quick-borg-backup","status":"publish","type":"post","link":"https:\/\/metajack.org\/blog\/2020\/11\/18\/creating-a-simple-quick-borg-backup\/","title":{"rendered":"Creating a simple, quick Borg backup"},"content":{"rendered":"\n<p>Here is how to create a simple borg backup. Something more along the lines of a zip file than a careful backup system. I&#8217;m using this method for long term storage. The primary benefits are de-duplication and compression.<\/p>\n\n\n\n<p>Again, to clarify &#8211; these are not backups meant to be updated each day\/week\/month. These are simply long term storage that I normally would have made by rsyncing or making a tgz.<\/p>\n\n\n\n<p>To create, run the following (see below for encrypted backup option):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># create an empty archive called test1\nborg init -e none test1 \n\n# add files to the archive\nborg create test1::first \/path\/to\/files\n\n# verify\/check the archive\nborg info test1<\/code><\/pre>\n\n\n\n<p>My test case gave 50% savings:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>                       Original size      Compressed size    Deduplicated size\nAll archives:               50.42 GB             35.15 GB             25.58 GB\n\n                       Unique chunks         Total chunks\nChunk index:                  215930               520240\n<\/code><\/pre>\n\n\n\n<p>Don&#8217;t forget that you can mount borg archives to browse files. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>borg mount test1::first \/mnt\/borg\nborg unmount \/mnt\/borg<\/code><\/pre>\n\n\n\n<p>Test restore on another host:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># bundle up the directory\ntar czpvf test1.borg.tgz test1<\/code><\/pre>\n\n\n\n<p>On another host:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># retrieve from original host\nwget http:\/\/yourdomain.com\/test1.borg.tgz\n\n# unpack the archive\ntar xzpvf test1.borg.tgz\n\n# check\/verify the archive\n\/usr\/local\/sbin\/borg info test1\nWarning: Attempting to access a previously unknown unencrypted repository!\nDo you want to continue? &#91;yN] y\n\n# create a directory to restore to\nmkdir restore\n\n# mount the archive\nborg mount test1 restore\/\n\n# work with the files in the archive\n# ls restore\n\n# umount the archive\nborg umount restore\n\n# extract all files from the archive\n# first, list the snapshots\nborg list test1\n\n# extract a snapshot\ncd restore\/\nborg extract ..\/test1::first <\/code><\/pre>\n\n\n\n<p>Creating an encrypted backup<\/p>\n\n\n\n<p>Adding encryption is easy :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># create an empty, encrypted archive called test1\n# enter the passphrase when prompted\nborg init -encryption=repokey test1 \n\n# export the key\nborg key export test1 test1.key\n\n# create the archive\n# enter passphrase when prompted\nborg create test1::first \/path\/to\/files\n\n<\/code><\/pre>\n\n\n\n<p>History:<\/p>\n\n\n\n<p>2020\/11\/18 at 3:56 pm<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here is how to create a simple borg backup. Something more along the lines of a zip file than a careful backup system. I&#8217;m using this method for long term storage. The primary benefits are de-duplication and compression. Again, to clarify &#8211; these are not backups meant to be updated each day\/week\/month. These are simply &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/metajack.org\/blog\/2020\/11\/18\/creating-a-simple-quick-borg-backup\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Creating a simple, quick Borg backup&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[34,33,32],"class_list":["post-267","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-backup","tag-borg","tag-sysadmin","entry"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/metajack.org\/blog\/wp-json\/wp\/v2\/posts\/267","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/metajack.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/metajack.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/metajack.org\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/metajack.org\/blog\/wp-json\/wp\/v2\/comments?post=267"}],"version-history":[{"count":6,"href":"https:\/\/metajack.org\/blog\/wp-json\/wp\/v2\/posts\/267\/revisions"}],"predecessor-version":[{"id":371,"href":"https:\/\/metajack.org\/blog\/wp-json\/wp\/v2\/posts\/267\/revisions\/371"}],"wp:attachment":[{"href":"https:\/\/metajack.org\/blog\/wp-json\/wp\/v2\/media?parent=267"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/metajack.org\/blog\/wp-json\/wp\/v2\/categories?post=267"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/metajack.org\/blog\/wp-json\/wp\/v2\/tags?post=267"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}