{"id":9426,"date":"2026-04-06T06:38:23","date_gmt":"2026-04-06T06:38:23","guid":{"rendered":"https:\/\/www.hostinger.com\/support\/?p=9426"},"modified":"2026-04-06T06:44:30","modified_gmt":"2026-04-06T06:44:30","slug":"how-to-use-rsync-to-sync-files-and-directories-at-hostinger","status":"publish","type":"post","link":"https:\/\/www.hostinger.com\/support\/how-to-use-rsync-to-sync-files-and-directories-at-hostinger\/","title":{"rendered":"How to use Rsync to sync files and directories at Hostinger"},"content":{"rendered":"<p data-path-to-node=\"7\"><b data-path-to-node=\"7\" data-index-in-node=\"0\">Rsync<\/b> (Remote Sync) is a command-line tool used to synchronize files and directories between two locations. It is highly efficient because it only sends the parts of files that have changed. This guide explains the default command logic and provides common examples for managing your <b data-path-to-node=\"7\" data-index-in-node=\"284\">Hostinger VPS<\/b> or <b data-path-to-node=\"7\" data-index-in-node=\"301\">managed hosting<\/b> files.<\/p><h2 data-path-to-node=\"8\" id=\"h-pre-requisites\">Pre-requisites<\/h2><ul>\n<li class=\"whitespace-normal break-words pl-2\"><strong>SSH access<\/strong> enabled on your source and destination.<\/li>\n<li class=\"whitespace-normal break-words pl-2\">A Hostinger hosting plan that supports SSH (available on all plans <strong>except Single Web hosting plan<\/strong>).<\/li>\n<li class=\"whitespace-normal break-words pl-2\">A terminal or command-line interface.<\/li>\n<\/ul><h2 data-path-to-node=\"11\" id=\"h-the-default-rsync-command-structure\">The default Rsync command structure<\/h2><p data-path-to-node=\"12\">Every Rsync command follows a standard syntax. Understanding this &ldquo;formula&rdquo; allows you to customize the transfer to fit your needs:<\/p><p data-path-to-node=\"13\"><code data-path-to-node=\"13\" data-index-in-node=\"0\">rsync [options] -e \"ssh -p port\" [source] [destination]<\/code><\/p><ul data-path-to-node=\"14\">\n<li>\n<p data-path-to-node=\"14,0,0\"><b data-path-to-node=\"14,0,0\" data-index-in-node=\"0\"><code data-path-to-node=\"14,0,0\" data-index-in-node=\"0\">[options]<\/code><\/b>: These define the behavior (e.g., <code data-path-to-node=\"14,0,0\" data-index-in-node=\"44\">-avz<\/code> for archive, verbose, and compression).<\/p>\n<\/li>\n<li>\n<p data-path-to-node=\"14,1,0\"><b data-path-to-node=\"14,1,0\" data-index-in-node=\"0\"><code data-path-to-node=\"14,1,0\" data-index-in-node=\"0\">-e \"ssh -p port\"<\/code><\/b>: This specifies the connection method and the SSH port. The correct port depends on your hosting type:<\/p>\n<ul class=\"[li_&amp;]:mb-0 [li_&amp;]:mt-1 [li_&amp;]:gap-1 [&amp;:not(:last-child)_ul]:pb-1 [&amp;:not(:last-child)_ol]:pb-1 list-disc flex flex-col gap-1 pl-8 mb-3\">\n<li class=\"whitespace-normal break-words pl-2\"><strong>Shared\/Cloud hosting:<\/strong> Hostinger uses port <strong>65002<\/strong> by default. You can confirm this on your hPanel under <strong>Advanced &rarr; SSH Access<\/strong>.<\/li>\n<li class=\"whitespace-normal break-words pl-2\"><strong>VPS hosting:<\/strong> The default port is <strong>22<\/strong>, unless you&rsquo;ve changed it.<\/li>\n<\/ul>\n<p class=\"font-claude-response-body break-words whitespace-normal leading-[1.7]\">All examples in this guide use <code class=\"bg-text-200\/5 border border-0.5 border-border-300 text-danger-000 whitespace-pre-wrap rounded-[0.4rem] px-1 py-px text-[0.9rem]\">-p 65002<\/code>. If you&rsquo;re on VPS with the default port, replace this with <code class=\"bg-text-200\/5 border border-0.5 border-border-300 text-danger-000 whitespace-pre-wrap rounded-[0.4rem] px-1 py-px text-[0.9rem]\">-p 22<\/code>.<\/p>\n<\/li>\n<li>\n<p data-path-to-node=\"14,2,0\"><b data-path-to-node=\"14,2,0\" data-index-in-node=\"0\"><code data-path-to-node=\"14,2,0\" data-index-in-node=\"0\">[source]<\/code><\/b>: The location of the files you want to move.<\/p>\n<\/li>\n<li>\n<p data-path-to-node=\"14,3,0\"><b data-path-to-node=\"14,3,0\" data-index-in-node=\"0\"><code data-path-to-node=\"14,3,0\" data-index-in-node=\"0\">[destination]<\/code><\/b>: Your server credentials and the path where you want the files to go.<\/p>\n<\/li>\n<\/ul><div class=\"intercom-interblocks-callout\" style=\"background-color: #e3e7fa80;border-color: #334bfa33\"><b data-path-to-node=\"15\" data-index-in-node=\"0\">TIP:<\/b> Always test your command by adding <code data-path-to-node=\"15\" data-index-in-node=\"44\">-n<\/code> or <code data-path-to-node=\"15\" data-index-in-node=\"50\">--dry-run<\/code> to the options. This simulates the transfer without making actual changes.<\/div><h2 data-path-to-node=\"30\" id=\"h-understanding-the-trailing-slash\">Understanding the &ldquo;Trailing Slash&rdquo; ( \/ )<\/h2><p data-path-to-node=\"17\">The presence of a slash at the end of the source path changes how the files are placed at the destination.<\/p><h4 data-path-to-node=\"18\">Option A: With a slash (<code data-path-to-node=\"18\" data-index-in-node=\"24\">source\/<\/code>)<\/h4><p data-path-to-node=\"19\">This tells Rsync to copy only the <b data-path-to-node=\"19\" data-index-in-node=\"34\">contents<\/b> of the folder. Use this when you want to move files directly into an existing directory on the server.<\/p><ul data-path-to-node=\"20\">\n<li>\n<p data-path-to-node=\"20,0,0\"><b data-path-to-node=\"20,0,0\" data-index-in-node=\"0\">Default format:<\/b> <code data-path-to-node=\"20,0,0\" data-index-in-node=\"16\">rsync [options] \/local-folder\/ user@ip:\/remote-folder\/<\/code><\/p>\n<\/li>\n<li>\n<p data-path-to-node=\"20,1,0\"><b data-path-to-node=\"20,1,0\" data-index-in-node=\"0\">Example:<\/b> <code data-path-to-node=\"20,1,0\" data-index-in-node=\"9\">rsync -avz ~\/Desktop\/my-files\/ user@ip:\/public_html\/<\/code><\/p>\n<\/li>\n<li>\n<p data-path-to-node=\"20,2,0\"><b data-path-to-node=\"20,2,0\" data-index-in-node=\"0\">Result:<\/b> The files inside <code data-path-to-node=\"20,2,0\" data-index-in-node=\"25\">my-files<\/code> will appear directly inside <code data-path-to-node=\"20,2,0\" data-index-in-node=\"62\">public_html<\/code>.<\/p>\n<\/li>\n<\/ul><h4 data-path-to-node=\"21\">Option B: Without a slash (<code data-path-to-node=\"21\" data-index-in-node=\"27\">source<\/code>)<\/h4><p data-path-to-node=\"22\">This tells Rsync to copy the <b data-path-to-node=\"22\" data-index-in-node=\"29\">entire folder itself<\/b>. Use this when you want to recreate the folder structure at the destination.<\/p><ul data-path-to-node=\"23\">\n<li>\n<p data-path-to-node=\"23,0,0\"><b data-path-to-node=\"23,0,0\" data-index-in-node=\"0\">Default format:<\/b> <code data-path-to-node=\"23,0,0\" data-index-in-node=\"16\">rsync [options] \/local-folder user@ip:\/remote-folder\/<\/code><\/p>\n<\/li>\n<li>\n<p data-path-to-node=\"23,1,0\"><b data-path-to-node=\"23,1,0\" data-index-in-node=\"0\">Example:<\/b> <code data-path-to-node=\"23,1,0\" data-index-in-node=\"9\">rsync -avz ~\/Desktop\/my-files user@ip:\/public_html\/<\/code><\/p>\n<\/li>\n<li>\n<p data-path-to-node=\"23,2,0\"><b data-path-to-node=\"23,2,0\" data-index-in-node=\"0\">Result:<\/b> You will see a new folder named <code data-path-to-node=\"23,2,0\" data-index-in-node=\"40\">my-files<\/code> inside your <code data-path-to-node=\"23,2,0\" data-index-in-node=\"61\">public_html<\/code> directory (<code data-path-to-node=\"23,2,0\" data-index-in-node=\"84\">\/public_html\/my-files\/<\/code>).<\/p>\n<\/li>\n<\/ul><h2 data-path-to-node=\"16\" id=\"h-common-sync-scenarios\">Common sync scenarios<\/h2><p data-path-to-node=\"17\">Once you understand the default structure, you can apply it to these common Hostinger workflows.<\/p><h4 data-path-to-node=\"18\">1. Uploading files to Hostinger (Push)<\/h4><p data-path-to-node=\"19\">To move a folder from your local computer to the server, use your local path as the source.<\/p><p data-path-to-node=\"20\"><b data-path-to-node=\"20\" data-index-in-node=\"0\">Default format:<\/b> <code data-path-to-node=\"20\" data-index-in-node=\"16\">rsync [options] -e \"ssh -p port\" \/local\/path\/ username@ip_address:\/remote\/path\/<\/code><\/p><p data-path-to-node=\"21\"><b data-path-to-node=\"21\" data-index-in-node=\"0\">Example:<\/b> <code data-path-to-node=\"21\" data-index-in-node=\"9\">rsync -avz -e \"ssh -p <code class=\"bg-text-200\/5 border border-0.5 border-border-300 text-danger-000 whitespace-pre-wrap rounded-[0.4rem] px-1 py-px text-[0.9rem]\">65002<\/code>\" ~\/Desktop\/website\/ u123456789@1.2.3.4:\/home\/u123456789\/domains\/domain.com\/public_html\/<\/code><\/p><h4 data-path-to-node=\"22\">2. Downloading files from Hostinger (Pull)<\/h4><p data-path-to-node=\"23\">To bring files from the server down to your computer, reverse the source and destination.<\/p><p data-path-to-node=\"24\"><b data-path-to-node=\"24\" data-index-in-node=\"0\">Default format:<\/b> <code data-path-to-node=\"24\" data-index-in-node=\"16\">rsync [options] -e \"ssh -p port\" username@ip_address:\/remote\/path\/ \/local\/path\/<\/code><\/p><p data-path-to-node=\"25\"><b data-path-to-node=\"25\" data-index-in-node=\"0\">Example:<\/b> <code data-path-to-node=\"25\" data-index-in-node=\"9\">rsync -avz -e \"ssh -p <code class=\"bg-text-200\/5 border border-0.5 border-border-300 text-danger-000 whitespace-pre-wrap rounded-[0.4rem] px-1 py-px text-[0.9rem]\">65002<\/code>\" u123456789@1.2.3.4:\/home\/u123456789\/domains\/domain.com\/public_html\/backup\/ ~\/Downloads\/<\/code><\/p><h4 data-path-to-node=\"26\">3. Creating an exact mirror<\/h4><p data-path-to-node=\"27\">To ensure the destination looks exactly like the source (deleting files at the destination that no longer exist at the source), add the <code data-path-to-node=\"27\" data-index-in-node=\"136\">--delete<\/code> flag.<\/p><p data-path-to-node=\"28\"><b data-path-to-node=\"28\" data-index-in-node=\"0\">Default format:<\/b> <code data-path-to-node=\"28\" data-index-in-node=\"16\">rsync [options] --delete -e \"ssh -p port\" [source] [destination]<\/code><\/p><p data-path-to-node=\"29\"><b data-path-to-node=\"29\" data-index-in-node=\"0\">Example:<\/b> <code data-path-to-node=\"29\" data-index-in-node=\"9\">rsync -avz --delete -e \"ssh -p 65002\" ~\/Desktop\/website\/ u123456789@1.2.3.4:\/home\/u123456789\/domains\/domain.com\/public_html\/<\/code><\/p><h2 data-path-to-node=\"33\" id=\"h-optional-synchronizing-databases\">Optional: Synchronizing databases<\/h2><p data-path-to-node=\"34\">If you are syncing a website with a database, files alone are not enough. You must export the database into a file so Rsync can &ldquo;see&rdquo; it and move it.<\/p><ol start=\"1\" data-path-to-node=\"35\">\n<li>\n<p data-path-to-node=\"35,0,0\"><b data-path-to-node=\"35,0,0\" data-index-in-node=\"0\">On the source:<\/b> Create a backup file: <code data-path-to-node=\"35,0,0\" data-index-in-node=\"37\">mysqldump -u db_user -p db_name &gt; data.sql<\/code><\/p>\n<\/li>\n<li>\n<p data-path-to-node=\"35,1,0\"><b data-path-to-node=\"35,1,0\" data-index-in-node=\"0\">Sync:<\/b> Run your Rsync command. If the <code data-path-to-node=\"35,1,0\" data-index-in-node=\"37\">data.sql<\/code> file is inside your website folder, it will be moved automatically. <b data-path-to-node=\"35,1,0\" data-index-in-node=\"114\">Example:<\/b> <code data-path-to-node=\"35,1,0\" data-index-in-node=\"123\">rsync -avz -e \"ssh -p 22\" ~\/Desktop\/website\/data.sql u123456789@1.2.3.4:\/home\/u123456789\/domains\/domain.com\/public_html\/<\/code><\/p>\n<\/li>\n<li>\n<p data-path-to-node=\"35,2,0\"><b data-path-to-node=\"35,2,0\" data-index-in-node=\"0\">On the destination:<\/b> Import the data into your new database: <code data-path-to-node=\"35,2,0\" data-index-in-node=\"60\">mysql -u db_user -p db_name &lt; data.sql<\/code><\/p>\n<\/li>\n<\/ol><p data-path-to-node=\"37\">By following the default Rsync structure, you can precisely control how data moves between your environments. Always verify your SSH port in hPanel and perform a dry run before executing a full synchronization.<\/p><p data-path-to-node=\"39,0,0\"><b data-path-to-node=\"39,0,0\" data-index-in-node=\"0\">NOTES<\/b><\/p><ul>\n<li class=\"whitespace-normal break-words pl-2\"><strong>SSH Port:<\/strong> Hostinger shared and cloud hosting uses port <strong>65002<\/strong> by default. VPS hosting uses port <strong>22<\/strong> by default. Always verify your port in hPanel under <strong>Advanced &rarr; SSH Access<\/strong> before running commands.<\/li>\n<li class=\"whitespace-normal break-words pl-2\"><strong>Progress:<\/strong> Add the <code class=\"bg-text-200\/5 border border-0.5 border-border-300 text-danger-000 whitespace-pre-wrap rounded-[0.4rem] px-1 py-px text-[0.9rem]\">-P<\/code> flag to see a progress bar for large transfers.<\/li>\n<li class=\"whitespace-normal break-words pl-2\"><strong>Unavailable on Single plans:<\/strong> Rsync requires SSH, which is not available on Single web hosting plans.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to use the Rsync utility to synchronize local and remote directories, create mirrors, and manage data transfers for your Hostinger services.<\/p>\n","protected":false},"author":594,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"include_on_kodee":true,"footnotes":""},"categories":[216],"tags":[],"class_list":["post-9426","post","type-post","status-publish","format-standard","hentry","category-general-information-features"],"hreflangs":[],"include_on_kodee":true,"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/9426","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/users\/594"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/comments?post=9426"}],"version-history":[{"count":3,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/9426\/revisions"}],"predecessor-version":[{"id":9429,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/9426\/revisions\/9429"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/media?parent=9426"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/categories?post=9426"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/tags?post=9426"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}