summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Smith <luke@lukesmith.xyz>2021-07-03 08:59:22 -0400
committerLuke Smith <luke@lukesmith.xyz>2021-07-03 08:59:22 -0400
commit8d4177c694b51c72f76c7bf39bc52f2b7bbd8769 (patch)
treef117f98c746b66bd2f44ce6011c9bf1921a6baec
parent950c610024df6589b8fc443e30c462e8854239c4 (diff)
rsync fixes
-rw-r--r--index.html4
-rw-r--r--rss.xml49
-rw-r--r--rsync.html50
3 files changed, 86 insertions, 17 deletions
diff --git a/index.html b/index.html
index b6a2dc8..4a3dce4 100644
--- a/index.html
+++ b/index.html
@@ -47,7 +47,8 @@
<h3 id=other>Excellent Extras</h3>
<ul class=ll>
- <li><a href="maintenance.html">How to maintain a server.</a></li>
+ <li><a href="rsync.html">Rsync: Upload and Sync Files and Websites</a></li>
+ <li><a href="maintenance.html">How to Maintain a Server.</a></li>
<li><a href="sshkeys.html">Use your SSH keys to prevent hacking.</a></li>
<li><a href="cron.html">Schedule tasks with Crontabs/Cronjobs.</a></li>
<li><a href="tor.html">Mirror your site on <img src="pix/tor.svg">Tor.</a></li>
@@ -88,7 +89,6 @@
<li>Full HTML tutorial</li>
<li>Full CSS tutorial</li>
<li>Setting up an Email server</li>
- <li>Using rsync for websites and servers.</li>
<li>RSS feeds</li>
<li>XMPP Prosody (federated chat)</li>
<li>Matrix (federated chat)</li>
diff --git a/rss.xml b/rss.xml
index a851064..198480c 100644
--- a/rss.xml
+++ b/rss.xml
@@ -16,6 +16,55 @@
<!-- LB -->
<item>
+<title>Rsync: Upload and Sync Files and Websites</title>
+<guid>https://landchad.net/rsync.html</guid>
+<link>https://landchad.net/rsync.html</link>
+<pubDate>Sat, 03 Jul 2021 08:58:29 -0400</pubDate>
+<description><![CDATA[
+<header><h1>Rsync: Upload and Sync Files and Websites</h1></header>
+<main>
+ <p>rsync is a simple way to copy files and folders between your local computer and server.</p>
+ <p>It not only makes file-transfer easy, but it allows you to build and maintain your website offline, then easily upload it to the proper directory on your server so you don't need to constantly be logged into your server to modify your site.</p>
+<h2 id="installing-rsync">Installing rsync</h2>
+<p>Run the following on your server <em>and</em> on your local machine.</p>
+<pre><code>apt install rsync</code></pre>
+<h2 id="uploading-files-with-rsync">Uploading files with rsync</h2>
+<p>From your local machine you can upload files to your server like this:</p>
+<pre><code>rsync -ruvzP <strong>/path/to/file</strong> <strong>root@example.org/path/on/the/server</strong></code></pre>
+<p>You will be prompted for the root password and then uploading will commence.</p>
+<p>If you omit <strong>root@</strong>, rsync will not attempt to log in as root, but whatever your local username is.</p>
+<h3>Options to rsync</h3>
+<p>In this command, we give several options to rsync:</p>
+<ul>
+ <li><code>-r</code> &ndash; run recurssively (include directories)</li>
+ <li><code>-u</code> &ndash; update files (do not reupload files that are not changed since last upload)</li>
+ <li><code>-v</code> &ndash; visual, show files uploaded</li>
+ <li><code>-z</code> &ndash; compress files for upload</li>
+ <li><code>-P</code> &ndash; if uploading a large file and upload breaks, pick up where we left off rather than reuploading the entire file</li>
+</ul>
+<p>Avoid using the commonly used <code>-a</code> option when uploading. It changes can transfer your local machine's user and group permissions to your server, which might cause breakage.</p>
+<h3>Scriptability</h3>
+<p>It's a good idea to build your website offline, then make an rsync script or bash alias like the one above to upload the edited files when you have made updates.</p>
+<h3>Password-less authentication</h3>
+<p>To avoid having to manually input your password each upload, you can set up <a href="sshkeys.html">SSH keys</a> to securely idenitify yourself and computer as a trusted.</p>
+<h3>Picky trailing slashes</h3>
+<p>rsync is very particular about trailing slashes. This is useful, but can be confusing to some new users. Suppose we run the following wanting to mirror our offline copy of our website in the directory we use on our server (<code>/var/www/websitefiles/</code>):</p>
+<pre><code>rsync -ruvzP ~/<strong>websitefiles/</strong> root@example.org:/var/www/<strong>websitefiles/</strong></code></pre>
+<p>This will <em>not actually do quite what we want</em>. It will take our local <code>websitefiles</code> directory and put it <em>inside</em> <code>websitefiles</code> on the remote machine, ending up with: <code>/var/www/websitefiles/websitefiles</code>.</p>
+<p>Instead, remove the trailing slash from the remote server location:</p>
+<pre><code>rsync -ruvzP ~/<strong>websitefiles/</strong> root@example.org:/var/www/<strong>websitefiles</strong></code></pre>
+<p><code>websitefiles/</code> has been replaced with <code>websitefiles</code>, and this will do what we want.</p>
+<h2 id="downloading-file-with-rsync">Downloading files with rsync</h2>
+<p>You may just as easily download files and directories from your server with rsync:</p>
+<pre><code>rsync -urvzP <strong>root@example.org:/path/to/file</strong> <strong>/path/to/file</strong></code></pre>
+<h2 id="contribution">Contribution</h2>
+<ul><li>el3ctr0lyte: <a href="https://github.com/el3ctr0lyte">github</a>, XMR: <code class=crypto>86DBJdiG83ZDea6kJgsbVN5tMae5ScfuhJ3PihEMTHatCrGEw2gctyUB92V2fz4R4YhwRaQeAGL5M4gPRXvVvtkULJi4ayk</code></li><li>Substantial revisions by <a href="https://lukesmith.xyz">Luke</a></li></ul>
+</main>
+]]></description>
+</item>
+
+
+<item>
<title>Setup a Pleroma Server</title>
<guid>https://landchad.net/pleroma.html</guid>
<link>https://landchad.net/pleroma.html</link>
diff --git a/rsync.html b/rsync.html
index dc9defb..da4bd15 100644
--- a/rsync.html
+++ b/rsync.html
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang=en>
<head>
- <title>Using rsync for your website or server</title>
+ <title>Rsync: Upload and Sync Files and Websites &ndash; LandChad.net</title>
<meta charset="utf-8"/>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
<link rel='stylesheet' type='text/css' href='style.css'>
@@ -10,26 +10,46 @@
</head>
<body>
-<header><h1 id="using-rsync-for-website-and-servers">Using rsync for website and servers</h1></header>
+<header><h1>Rsync: Upload and Sync Files and Websites</h1></header>
<nav></nav>
<main>
-<p>So you have a website and you have ssh setup on your server. Rsync is a way of uploading and downloading files to and from your server. Here is how.</p>
+ <p>rsync is a simple way to copy files and folders between your local computer and server.</p>
+ <p>It not only makes file-transfer easy, but it allows you to build and maintain your website offline, then easily upload it to the proper directory on your server so you don't need to constantly be logged into your server to modify your site.</p>
<h2 id="installing-rsync">Installing rsync</h2>
-<p>Run the following on your server and on your local machine.</p>
+<p>Run the following on your server <em>and</em> on your local machine.</p>
<pre><code>apt install rsync</code></pre>
<h2 id="uploading-files-with-rsync">Uploading files with rsync</h2>
<p>From your local machine you can upload files to your server like this:</p>
-<pre><code>rsync -avz /path/to/file landchad.net:/path/on/the/server</code></pre>
-<p>You will be prompted to enter a password. By default it will use the username that you are logged in with on you local machine. To use a different user, do this:</p>
-<pre><code>rsync -avz /path/to/file username@landchad.net:/path/on/the/server</code></pre>
-<h2 id="downloading-file-with-rsync">Downloading file with rsync</h2>
-<p>Basically like downloading, you just swap the last two arguments, like this:</p>
-<pre><code>rsync -avz landchad.net:/path/to/file /path/to/file</code></pre>
-<p>Again, with a different username on you server:</p>
-<pre><code>rsync -avz username@landchad.net:/path/to/file /path/to/file</code></pre>
-<h3 id="contribution">Contribution</h3>
-<p>el3ctr0lyte: <a href="https://github.com/el3ctr0lyte">github</a>, XMR: <code>86DBJdiG83ZDea6kJgsbVN5tMae5ScfuhJ3PihEMTHatCrGEw2gctyUB92V2fz4R4YhwRaQeAGL5M4gPRXvVvtkULJi4ayk</code></p>
+<pre><code>rsync -ruvzP <strong>/path/to/file</strong> <strong>root@example.org/path/on/the/server</strong></code></pre>
+<p>You will be prompted for the root password and then uploading will commence.</p>
+<p>If you omit <strong>root@</strong>, rsync will not attempt to log in as root, but whatever your local username is.</p>
+<h3>Options to rsync</h3>
+<p>In this command, we give several options to rsync:</p>
+<ul>
+ <li><code>-r</code> &ndash; run recurssively (include directories)</li>
+ <li><code>-u</code> &ndash; update files (do not reupload files that are not changed since last upload)</li>
+ <li><code>-v</code> &ndash; visual, show files uploaded</li>
+ <li><code>-z</code> &ndash; compress files for upload</li>
+ <li><code>-P</code> &ndash; if uploading a large file and upload breaks, pick up where we left off rather than reuploading the entire file</li>
+</ul>
+<p>Avoid using the commonly used <code>-a</code> option when uploading. It changes can transfer your local machine's user and group permissions to your server, which might cause breakage.</p>
+<h3>Scriptability</h3>
+<p>It's a good idea to build your website offline, then make an rsync script or bash alias like the one above to upload the edited files when you have made updates.</p>
+<h3>Password-less authentication</h3>
+<p>To avoid having to manually input your password each upload, you can set up <a href="sshkeys.html">SSH keys</a> to securely idenitify yourself and computer as a trusted.</p>
+<h3>Picky trailing slashes</h3>
+<p>rsync is very particular about trailing slashes. This is useful, but can be confusing to some new users. Suppose we run the following wanting to mirror our offline copy of our website in the directory we use on our server (<code>/var/www/websitefiles/</code>):</p>
+<pre><code>rsync -ruvzP ~/<strong>websitefiles/</strong> root@example.org:/var/www/<strong>websitefiles/</strong></code></pre>
+<p>This will <em>not actually do quite what we want</em>. It will take our local <code>websitefiles</code> directory and put it <em>inside</em> <code>websitefiles</code> on the remote machine, ending up with: <code>/var/www/websitefiles/websitefiles</code>.</p>
+<p>Instead, remove the trailing slash from the remote server location:</p>
+<pre><code>rsync -ruvzP ~/<strong>websitefiles/</strong> root@example.org:/var/www/<strong>websitefiles</strong></code></pre>
+<p><code>websitefiles/</code> has been replaced with <code>websitefiles</code>, and this will do what we want.</p>
+<h2 id="downloading-file-with-rsync">Downloading files with rsync</h2>
+<p>You may just as easily download files and directories from your server with rsync:</p>
+<pre><code>rsync -urvzP <strong>root@example.org:/path/to/file</strong> <strong>/path/to/file</strong></code></pre>
+<h2 id="contribution">Contribution</h2>
+<ul><li>el3ctr0lyte: <a href="https://github.com/el3ctr0lyte">github</a>, XMR: <code class=crypto>86DBJdiG83ZDea6kJgsbVN5tMae5ScfuhJ3PihEMTHatCrGEw2gctyUB92V2fz4R4YhwRaQeAGL5M4gPRXvVvtkULJi4ayk</code></li><li>Substantial revisions by <a href="https://lukesmith.xyz">Luke</a></li></ul>
</main>
-<footer><a href="https://landchad.net">LandChad.net</a></br>Because Everyone should be an Internet LandChad.</br><li><a href="index.html"><img src="pix/chad.gif" alt="chad"></a></li><li><a href="rss.xml"><img src="pix/rss.svg" alt="RSS"></a></li><li><a href="pix/btc.png"><img src="pix/btc.svg" alt="BTC"></a></li><li><a href="pix/xmr.png"><img src="pix/xmr.svg" alt="XMR"></a></li><li><a href="https://github.com/lukesmithxyz/landchad"><img src="pix/git.svg" alt="Github"></a></footer>
+<footer><a href="https://landchad.net">LandChad.net</a></br>Because Everyone should be an Internet LandChad.</br><a href="index.html"><li><img src="pix/chad.gif" alt="chad"></li></a><a href="rss.xml"><li><img src="pix/rss.svg" alt="RSS"></li></a><a href="pix/btc.png"><li><img src="pix/btc.svg" alt="BTC"></li></a><a href="pix/xmr.png"><li><img src="pix/xmr.svg" alt="XMR"></li></a><a href="https://github.com/lukesmithxyz/landchad"><li><img src="pix/git.svg" alt="Github"></li></a></footer>
</body>
</html>