{"id":614,"date":"2026-07-19T09:07:34","date_gmt":"2026-07-19T09:07:34","guid":{"rendered":"https:\/\/virtualserversvps.com\/blog\/?p=614"},"modified":"2026-08-22T22:09:27","modified_gmt":"2026-08-22T22:09:27","slug":"vps-automated-backups-with-rsync-and-cron-a-step-by-step-technical-guide","status":"publish","type":"post","link":"https:\/\/virtualserversvps.com\/blog\/vps-automated-backups-with-rsync-and-cron-a-step-by-step-technical-guide\/","title":{"rendered":"rsync and cron Backups on a VPS: A Reliable Pipeline That Costs Nothing Extra"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Backup software is a crowded market: Borg, restic, rclone, and a dozen hosted services all promise bulletproof recovery. For a single VPS, though, the most underrated setup is also the oldest: <code>rsync<\/code> plus <code>cron<\/code>. Both ship with virtually every Linux distribution, the pipeline is easy to audit line by line, and there is no subscription fee. What separates a real backup system from a folder of copies is design discipline \u2014 this guide covers the pipeline, the retention scheme, and the restore drill that makes it trustworthy.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The three-stage pipeline<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Every serious backup has three stages: capture the data in a consistent state, stage it locally, then push it offsite. Stage one dumps databases and snapshots files into a staging directory. Stage two holds that staging copy long enough for the transfer to complete. Stage three pushes it to a host that is not your VPS \u2014 ideally a different provider or region, so a datacenter outage does not take your backups with it. If you have not decided where your production box lives yet, <a href=\"https:\/\/virtualserversvps.com\/#providers\">our VPS comparison table<\/a> is a good place to start comparing regions and plans.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Dump databases without locking your app<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Files can be copied while the server runs, but databases need a consistent snapshot. Use the non-locking dump flags so your application never stalls:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># MySQL \/ MariaDB: consistent snapshot without blocking writes\nmysqldump --single-transaction --routines --triggers myapp &gt; \/var\/backups\/staging\/myapp.sql\n\n# PostgreSQL: custom format compresses well and restores selectively\npg_dump -Fc myapp &gt; \/var\/backups\/staging\/myapp.dump\n\n# SQLite: use the online backup API, not a raw file copy\nsqlite3 \/var\/lib\/myapp\/app.db \".backup '\/var\/backups\/staging\/app.db'\"<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Write dumps into the same staging directory that rsync later mirrors, so one transfer covers both files and databases.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Push offsite over SSH<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The transfer itself is a single rsync invocation. Create a dedicated user on the backup host with no shell and an SSH key restricted to rsync; then run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>rsync -az --delete --partial \\\n  -e \"ssh -i \/root\/.ssh\/backup_key -p 2222\" \\\n  \/var\/backups\/staging\/ \\\n  backup@backup-host.example:\/backups\/vps1\/current\/<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><code>-a<\/code> preserves permissions and timestamps, <code>--partial<\/code> resumes an interrupted transfer instead of restarting it, and <code>--delete<\/code> mirrors deletions so the offsite copy matches the staging directory exactly. Combined with the hardlink rotation below, <code>--delete<\/code> is what keeps snapshots honest without duplicating storage.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Retention with hardlink rotation<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Rotating snapshots normally means copying data N times. With <code>--link-dest<\/code>, unchanged files become hardlinks to the previous snapshot, so 14 snapshots cost barely more than one full backup plus the bytes that actually changed. The rotation script shifts directories before each run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>rm -rf \/backups\/vps1\/backup.3\nmv \/backups\/vps1\/backup.2 \/backups\/vps1\/backup.3\nmv \/backups\/vps1\/backup.1 \/backups\/vps1\/backup.2\nmv \/backups\/vps1\/backup.0 \/backups\/vps1\/backup.1\n\nrsync -a --delete --link-dest=..\/backup.1 \\\n  \/var\/backups\/staging\/ \/backups\/vps1\/backup.0\/<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Retention tier<\/th><th>Copies kept<\/th><th>Extra disk cost<\/th><\/tr><\/thead><tbody><tr><td>Daily<\/td><td>7<\/td><td>~size of one backup (hardlinked)<\/td><\/tr><tr><td>Weekly<\/td><td>4<\/td><td>~same, hardlinked<\/td><\/tr><tr><td>Monthly<\/td><td>3<\/td><td>~same, hardlinked<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Because unchanged files are hardlinks, a month of daily snapshots typically occupies only slightly more space than a single full backup plus the changed bytes.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Schedule it like a human<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">cron is the obvious choice, but pick an odd minute so your backup does not collide with everyone else&#8217;s 03:00 stampede, and log the exit status:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>17 3 * * * \/usr\/local\/sbin\/vps-backup.sh &gt;&gt; \/var\/log\/vps-backup.log 2&gt;&amp;1<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If you prefer systemd, a timer with <code>OnCalendar=*-*-* 03:17:00<\/code> and <code>Persistent=true<\/code> catches up after a reboot \u2014 something cron silently skips. Whichever you use, wire the script&#8217;s exit code to a notification (cron mail, or a healthchecks.io ping). A backup that fails silently is not a backup at all.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The restore drill<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Backups you have never restored are guesses. Once a month, on a scratch VPS or container: restore the database dump and verify row counts, unpack the file snapshot and compare checksums with <code>diff -r<\/code>, and time the whole procedure. Record the elapsed time in the backup log \u2014 if a restore starts taking hours, you want to discover that now, not during an incident. It also keeps the drill honest: <a href=\"https:\/\/virtualserversvps.com\/\">run your VPS workload<\/a> against the restored copy for a few minutes to catch missing directories or wrong permissions.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Encrypt what leaves your server<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If the backup host is a machine you control, SSH transport encryption may be enough. If backups land on object storage or a third-party host, encrypt the dumps with <code>age<\/code> or GPG before staging them. One trade-off: encryption defeats rsync&#8217;s hardlink dedup for those files, so encrypt only the database dumps and keep plain files for the file tree, or use a tool like rclone crypt for object storage.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The whole pipeline runs on software you already have, which means the only real cost is discipline. If you are setting up a second VPS as the offsite target, <a href=\"https:\/\/virtualserversvps.com\/#providers\">compare providers on our VPS comparison table<\/a> \u2014 a cheap box in a different region is all this design needs.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Looking for a host for both the production server and the backup target? <a href=\"https:\/\/interserver.net\/vps?id=1067805&amp;sid=virtualserversvps\" rel=\"noreferrer noopener sponsored\" target=\"_blank\">InterServer&#8217;s VPS plans<\/a> are priced low enough that a dedicated backup VPS in a second location is a realistic addition to any setup.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Backup software is a crowded market: Borg, restic, rclone, and a dozen hosted services all promise bulletproof recovery. For a single VPS, though, the most underrated setup is also the&#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":3,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-614","post","type-post","status-publish","format-standard","hentry","category-performance-optimization"],"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>rsync and cron Backups on a VPS: A Reliable Pipeline That Costs Nothing Extra - 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-automated-backups-with-rsync-and-cron-a-step-by-step-technical-guide\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"rsync and cron Backups on a VPS: A Reliable Pipeline That Costs Nothing Extra\" \/>\n<meta property=\"og:description\" content=\"rsync and cron Backups on a VPS: A Reliable Pipeline That Costs Nothing Extra\" \/>\n<meta property=\"og:url\" content=\"https:\/\/virtualserversvps.com\/blog\/vps-automated-backups-with-rsync-and-cron-a-step-by-step-technical-guide\/\" \/>\n<meta property=\"og:site_name\" content=\"Virtual Servers VPS Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-07-19T09:07:34+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-08-22T22:09:27+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=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/vps-automated-backups-with-rsync-and-cron-a-step-by-step-technical-guide\/\",\"url\":\"https:\/\/virtualserversvps.com\/blog\/vps-automated-backups-with-rsync-and-cron-a-step-by-step-technical-guide\/\",\"name\":\"rsync and cron Backups on a VPS: A Reliable Pipeline That Costs Nothing Extra - Virtual Servers VPS Blog\",\"isPartOf\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#website\"},\"datePublished\":\"2026-07-19T09:07:34+00:00\",\"dateModified\":\"2026-08-22T22:09:27+00:00\",\"author\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0\"},\"breadcrumb\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/vps-automated-backups-with-rsync-and-cron-a-step-by-step-technical-guide\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/virtualserversvps.com\/blog\/vps-automated-backups-with-rsync-and-cron-a-step-by-step-technical-guide\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/vps-automated-backups-with-rsync-and-cron-a-step-by-step-technical-guide\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/virtualserversvps.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"rsync and cron Backups on a VPS: A Reliable Pipeline That Costs Nothing Extra\"}]},{\"@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":"rsync and cron Backups on a VPS: A Reliable Pipeline That Costs Nothing Extra - 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-automated-backups-with-rsync-and-cron-a-step-by-step-technical-guide\/","og_locale":"en_US","og_type":"article","og_title":"rsync and cron Backups on a VPS: A Reliable Pipeline That Costs Nothing Extra","og_description":"rsync and cron Backups on a VPS: A Reliable Pipeline That Costs Nothing Extra","og_url":"https:\/\/virtualserversvps.com\/blog\/vps-automated-backups-with-rsync-and-cron-a-step-by-step-technical-guide\/","og_site_name":"Virtual Servers VPS Blog","article_published_time":"2026-07-19T09:07:34+00:00","article_modified_time":"2026-08-22T22:09:27+00:00","author":"Virtual-Servers-Vps-Editor","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Virtual-Servers-Vps-Editor","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/virtualserversvps.com\/blog\/vps-automated-backups-with-rsync-and-cron-a-step-by-step-technical-guide\/","url":"https:\/\/virtualserversvps.com\/blog\/vps-automated-backups-with-rsync-and-cron-a-step-by-step-technical-guide\/","name":"rsync and cron Backups on a VPS: A Reliable Pipeline That Costs Nothing Extra - Virtual Servers VPS Blog","isPartOf":{"@id":"https:\/\/virtualserversvps.com\/blog\/#website"},"datePublished":"2026-07-19T09:07:34+00:00","dateModified":"2026-08-22T22:09:27+00:00","author":{"@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0"},"breadcrumb":{"@id":"https:\/\/virtualserversvps.com\/blog\/vps-automated-backups-with-rsync-and-cron-a-step-by-step-technical-guide\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/virtualserversvps.com\/blog\/vps-automated-backups-with-rsync-and-cron-a-step-by-step-technical-guide\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/virtualserversvps.com\/blog\/vps-automated-backups-with-rsync-and-cron-a-step-by-step-technical-guide\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/virtualserversvps.com\/blog\/"},{"@type":"ListItem","position":2,"name":"rsync and cron Backups on a VPS: A Reliable Pipeline That Costs Nothing Extra"}]},{"@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\/614","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=614"}],"version-history":[{"count":2,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/614\/revisions"}],"predecessor-version":[{"id":946,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/614\/revisions\/946"}],"wp:attachment":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/media?parent=614"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/categories?post=614"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/tags?post=614"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}