{"id":956,"date":"2026-08-23T23:11:25","date_gmt":"2026-08-23T23:11:25","guid":{"rendered":"https:\/\/virtualserversvps.com\/blog\/?p=956"},"modified":"2026-08-23T23:11:25","modified_gmt":"2026-08-23T23:11:25","slug":"vps-backups-restic-backblaze-b2","status":"publish","type":"post","link":"https:\/\/virtualserversvps.com\/blog\/vps-backups-restic-backblaze-b2\/","title":{"rendered":"Automating VPS Backups with restic and Backblaze B2 on a Budget"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Backing up a VPS is not optional, but traditional backup solutions can be expensive or complex to set up. Restic is a fast, encrypted, open-source backup tool that deduplicates data across backups. Backblaze B2 provides low-cost object storage at $0.006\/GB\/month. Together, they form a backup stack that costs pennies per month for a typical single-VPS setup. This guide walks through the full setup: installation, configuration, automation, and restore testing.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why restic + B2?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Three things make this combination compelling for a budget VPS:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Deduplication.<\/strong> Restic splits files into chunks and only stores new chunks. Daily backups of a 10 GB VPS typically consume 100-200 MB of new storage per day, keeping B2 costs under $1\/month.<\/li>\n<li><strong>Encryption.<\/strong> All data is encrypted client-side with AES-256-GCM before leaving your VPS. B2 never sees plaintext \u2014 your data is safe even if someone gains access to your bucket.<\/li>\n<li><strong>Snapshots.<\/strong> Restic creates point-in-time snapshots that you can browse, mount, or restore selectively. You can restore a single file, a directory, or the entire backup.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A VPS running Linux (Ubuntu\/Debian shown, but restic works on any distribution)<\/li>\n<li>A Backblaze B2 account (free tier: 10 GB storage, 1 GB daily egress)<\/li>\n<li>A B2 application key with read\/write access to a dedicated bucket<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Step 1: Install restic<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Restic is available in most package managers. The official repository provides the latest version:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Ubuntu\/Debian\nsudo apt install restic\n\n# Verify installation\nrestic version<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2: Create a B2 Bucket and Application Key<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Log into your Backblaze B2 account and:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Create a new private bucket (name it something like <code>vps-backups-$(hostname)<\/code>).<\/li>\n<li>Generate an application key with read\/write access to <strong>only that bucket<\/strong> (not your master key). This limits the blast radius if the key is compromised.<\/li>\n<li>Save the <strong>keyID<\/strong> and <strong>applicationKey<\/strong> \u2014 you will need them for the restic configuration.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Step 3: Initialize the restic Repository<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">On your VPS, set environment variables for the B2 credentials and initialize the repository:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Set environment variables (temporary - we will make them permanent later)\nexport B2_ACCOUNT_ID=\"your-key-id\"\nexport B2_ACCOUNT_KEY=\"your-application-key\"\n\n# Initialize the repository in your B2 bucket\nrestic -r b2:your-bucket-name init\n\n# You will be prompted for a repository password\n# This password is used to encrypt\/decrypt your backups\n# Store it in a password manager - if you lose it, your backups are unrecoverable<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 4: Create Your First Backup<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Run a manual backup to verify the setup works. A typical VPS backup includes the entire filesystem, excluding system pseudo-filesystems and temporary directories:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Create a backup of the entire root filesystem, excluding \/proc, \/sys, \/dev, \/tmp, \/mnt\nrestic -r b2:your-bucket-name backup   --exclude \/proc   --exclude \/sys   --exclude \/dev   --exclude \/tmp   --exclude \/run   --exclude \/mnt   --exclude \/media   --exclude \/lost+found   \/<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">For a database-driven application, add pre-backup scripts to dump your databases. Restic supports <code>--pre-backup-command<\/code> and <code>--post-backup-command<\/code> hooks:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Backup with MySQL dump before the file snapshot\nrestic -r b2:your-bucket-name backup   --pre-backup-command \"mysqldump --all-databases --single-transaction &gt; \/tmp\/mysql-dump.sql\"   --post-backup-command \"rm \/tmp\/mysql-dump.sql\"   --exclude \/proc --exclude \/sys --exclude \/dev --exclude \/tmp   --exclude \/run --exclude \/mnt --exclude \/lost+found   \/<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 5: Verify the Backup<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">After the first backup completes, verify the repository integrity and list your snapshots:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Check repository integrity\nrestic -r b2:your-bucket-name check\n\n# List snapshots\nrestic -r b2:your-bucket-name snapshots\n\n# View the contents of a specific snapshot\nrestic -r b2:your-bucket-name ls latest<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 6: Automate Daily Backups<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Create a backup script at <code>\/usr\/local\/bin\/vps-backup.sh<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\n# \/usr\/local\/bin\/vps-backup.sh - Restic backup to Backblaze B2\nset -euo pipefail\n\n# Configuration\nexport B2_ACCOUNT_ID=\"your-key-id\"\nexport B2_ACCOUNT_KEY=\"your-application-key\"\nexport RESTIC_REPOSITORY=\"b2:your-bucket-name\"\nexport RESTIC_PASSWORD=\"your-repository-password\"\n\n# Database dump (if applicable)\nmysqldump --all-databases --single-transaction &gt; \/tmp\/pre-backup-dump.sql 2&gt;\/dev\/null || true\n\n# Run the backup\nrestic backup   --exclude \/proc --exclude \/sys --exclude \/dev   --exclude \/tmp --exclude \/run --exclude \/mnt   --exclude \/lost+found   --exclude \/var\/cache\/apt   --exclude \/var\/cache\/dnf   --exclude \"*.log\"   --tag \"daily\"   \/ 2&gt;&amp;1\n\n# Clean up\nrm -f \/tmp\/pre-backup-dump.sql\n\n# Remove snapshots older than 30 days\nrestic forget --keep-daily 7 --keep-weekly 4 --keep-monthly 3 --prune 2&gt;&amp;1\n\n# Check repository integrity (weekly, on Sundays)\nif [ \"$(date +%u)\" -eq 7 ]; then\n  restic check 2&gt;&amp;1\nfi<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Make it executable and add a cron job:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo chmod +x \/usr\/local\/bin\/vps-backup.sh\n\n# Add to crontab (runs daily at 2 AM)\nsudo crontab -e\n# Add this line:\n# 0 2 * * * \/usr\/local\/bin\/vps-backup.sh &gt;&gt; \/var\/log\/vps-backup.log 2&gt;&amp;1<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 7: Test Restore (The Most Important Step)<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A backup you have never restored is not a backup. Test restoring a single file and a full snapshot:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Restore a single file from the latest snapshot\nrestic -r b2:your-bucket-name restore latest   --path \/etc\/nginx\/nginx.conf   --target \/tmp\/restore-test\/\n\n# Restore an entire snapshot to a temporary directory\nrestic -r b2:your-bucket-name restore latest   --target \/tmp\/full-restore-test\/\n\n# Mount a snapshot as a filesystem (read-only)\nrestic -r b2:your-bucket-name mount \/mnt\/restic-mount<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Verify the restored files are complete and the database dumps are importable. Document the restore procedure in a runbook \u2014 you do not want to figure it out under pressure.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Cost Analysis<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">For a typical 20 GB VPS with daily backups and 30-day retention:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Component<\/th><th>Cost<\/th><\/tr><\/thead><tbody><tr><td>B2 storage (initial ~2 GB, ~200 MB\/day new)<\/td><td>~$0.06\/month<\/td><\/tr><tr><td>B2 Class B transactions (write\/list)<\/td><td>~$0.01\/month<\/td><\/tr><tr><td>B2 Class C transactions (read)<\/td><td>~$0.00\/month (minimal)<\/td><\/tr><tr><td><strong>Total<\/strong><\/td><td><strong>~$0.07\/month<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Compare this to managed backup services that charge $5-20\/month, or to S3 standard storage at $0.023\/GB\/month. The restic + B2 combination is the cheapest production-grade backup solution for a single VPS.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Security Considerations<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Never store the repository password in the script file on a production server<\/strong> if you share the server. Use a restricted environment file (<code>\/etc\/restic\/env<\/code> with <code>chmod 600<\/code>) or a secrets manager.<\/li>\n<li><strong>Use a dedicated B2 application key<\/strong> scoped to one bucket. Do not use your master B2 key.<\/li>\n<li><strong>Test the backup without the key set<\/strong> to confirm that the backups are indeed encrypted and inaccessible without the password.<\/li>\n<li><strong>Keep a copy of the repository password offline<\/strong> \u2014 in a password manager, not on the VPS. If you lose both the VPS and the password, your backups are gone.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Next Steps<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Once your backup automation is running, consider adding monitoring: pipe the backup log to a health check service (like Uptime Kuma or Healthchecks.io) so you know when a backup fails. Set up a monthly calendar reminder to do a full restore test. And when comparing VPS providers for your next server, check the <a href=\"https:\/\/virtualserversvps.com\/#providers\">VPS provider comparison table<\/a> to see which ones offer the storage and bandwidth specs that fit your backup strategy.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Backing up a VPS is not optional, but traditional backup solutions can be expensive or complex to set up. Restic is a fast, encrypted, open-source backup tool that deduplicates data&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":0,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-956","post","type-post","status-publish","format-standard","hentry","category-vps-guides-tutorials"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.1 (Yoast SEO v26.1) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Automating VPS Backups with restic and Backblaze B2 on a Budget - Virtual Servers VPS Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/virtualserversvps.com\/blog\/vps-backups-restic-backblaze-b2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Automating VPS Backups with restic and Backblaze B2 on a Budget\" \/>\n<meta property=\"og:description\" content=\"Automating VPS Backups with restic and Backblaze B2 on a Budget\" \/>\n<meta property=\"og:url\" content=\"https:\/\/virtualserversvps.com\/blog\/vps-backups-restic-backblaze-b2\/\" \/>\n<meta property=\"og:site_name\" content=\"Virtual Servers VPS Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-23T23:11:25+00:00\" \/>\n<meta name=\"author\" content=\"Virtual-Servers-Vps-Editor\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Virtual-Servers-Vps-Editor\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/vps-backups-restic-backblaze-b2\/\",\"url\":\"https:\/\/virtualserversvps.com\/blog\/vps-backups-restic-backblaze-b2\/\",\"name\":\"Automating VPS Backups with restic and Backblaze B2 on a Budget - Virtual Servers VPS Blog\",\"isPartOf\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#website\"},\"datePublished\":\"2026-08-23T23:11:25+00:00\",\"author\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0\"},\"breadcrumb\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/vps-backups-restic-backblaze-b2\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/virtualserversvps.com\/blog\/vps-backups-restic-backblaze-b2\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/vps-backups-restic-backblaze-b2\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/virtualserversvps.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Automating VPS Backups with restic and Backblaze B2 on a Budget\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#website\",\"url\":\"https:\/\/virtualserversvps.com\/blog\/\",\"name\":\"Virtual Servers VPS Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/virtualserversvps.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0\",\"name\":\"Virtual-Servers-Vps-Editor\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g\",\"caption\":\"Virtual-Servers-Vps-Editor\"},\"sameAs\":[\"https:\/\/virtualserversvps.com\/blog\"],\"url\":\"https:\/\/virtualserversvps.com\/blog\/author\/virtualserversvps\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Automating VPS Backups with restic and Backblaze B2 on a Budget - Virtual Servers VPS Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/virtualserversvps.com\/blog\/vps-backups-restic-backblaze-b2\/","og_locale":"en_US","og_type":"article","og_title":"Automating VPS Backups with restic and Backblaze B2 on a Budget","og_description":"Automating VPS Backups with restic and Backblaze B2 on a Budget","og_url":"https:\/\/virtualserversvps.com\/blog\/vps-backups-restic-backblaze-b2\/","og_site_name":"Virtual Servers VPS Blog","article_published_time":"2026-08-23T23:11:25+00:00","author":"Virtual-Servers-Vps-Editor","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Virtual-Servers-Vps-Editor","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/virtualserversvps.com\/blog\/vps-backups-restic-backblaze-b2\/","url":"https:\/\/virtualserversvps.com\/blog\/vps-backups-restic-backblaze-b2\/","name":"Automating VPS Backups with restic and Backblaze B2 on a Budget - Virtual Servers VPS Blog","isPartOf":{"@id":"https:\/\/virtualserversvps.com\/blog\/#website"},"datePublished":"2026-08-23T23:11:25+00:00","author":{"@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0"},"breadcrumb":{"@id":"https:\/\/virtualserversvps.com\/blog\/vps-backups-restic-backblaze-b2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/virtualserversvps.com\/blog\/vps-backups-restic-backblaze-b2\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/virtualserversvps.com\/blog\/vps-backups-restic-backblaze-b2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/virtualserversvps.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Automating VPS Backups with restic and Backblaze B2 on a Budget"}]},{"@type":"WebSite","@id":"https:\/\/virtualserversvps.com\/blog\/#website","url":"https:\/\/virtualserversvps.com\/blog\/","name":"Virtual Servers VPS Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/virtualserversvps.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0","name":"Virtual-Servers-Vps-Editor","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g","caption":"Virtual-Servers-Vps-Editor"},"sameAs":["https:\/\/virtualserversvps.com\/blog"],"url":"https:\/\/virtualserversvps.com\/blog\/author\/virtualserversvps\/"}]}},"_links":{"self":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/956","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/comments?post=956"}],"version-history":[{"count":1,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/956\/revisions"}],"predecessor-version":[{"id":957,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/956\/revisions\/957"}],"wp:attachment":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/media?parent=956"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/categories?post=956"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/tags?post=956"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}