Add content to rdiff/rsync guides

master
Nathan Steel 4 years ago
parent 37bfe9fb21
commit 5c9bebfa2b

@ -30,11 +30,17 @@
<main> <main>
<section> <section>
<p class="intro">Like rsync, rdiff-backup is a tool used for incremental backups. Unlike rsync, however rdiff keeps the most-recent file, along with any changes, deletions, etc.</p> <p class="intro">Like rsync, rdiff-backup is a tool used for incremental backups. Unlike rsync however, rdiff keeps the most-recent file change, along with any previous changes, deletions, etc.</p>
<h2>Install</h2> <h2>Install</h2>
<pre><code>sudo apt install rdiff-backup</code></pre>
<h2>Backup</h2> <h2>Backup</h2>
<pre><code>rdiff-backup $dir $backup</code></pre>
<h2>Restore</h2> <h2>Restore</h2>
<pre><code>rdiff-backup -r 2D $backup $restore_dir</code></pre>
<h2>Advanced</h2> <h2>Advanced</h2>
<h3>Only keep backups for a certain time period</h3>
<pre><code>rdiff-backup --force --remove-older-than 2M $backup</code></pre>
<p>This will remove all backups older than 2 months from $backup.</p>
</section> </section>
</main> </main>

@ -30,11 +30,48 @@
<main> <main>
<section> <section>
<p class="intro">rsync</p> <p class="intro">Rsync is a program that allows for incremental backups. This means that rsync will not create an additional copy of the data when backing up, it will only backup changes to the files/directories, saving bandwidth and storage space.</p>
<h2>Installation</h2> <h2>Installation</h2>
<pre><code>sudo apt install rsync</code></pre>
<h2>Backup</h2> <h2>Backup</h2>
<pre><code>rsync -azh $ORIGINAL $BACKUP</code></pre>
<p>Replace $ORIGINAL with the file/directory to backup, and $BACKUP with the location for the backup to reside.</p>
<p>The $BACKUP destination must be a blank directory, an rsync directory, or not currently exist.</p>
<h3>Remote rsync backup</h3>
<p>If you need to rsync from one PC to another, it's essential the same command, but with the additional layer of ssh</p>
<pre><code>rsync -azh -e ssh $ORIGINAL $BACKUP</code></pre>
<p>$BACKUP here will be an ssh connection pointed to a location, much like when using scp, so the command will look like</p>
<pre><code>rsync -azh -e ssh $ORIGINAL $USER@$HOST:$LOCATION</code></pre>
<p>Replacing $USER and $HOST with the username and hostname/IP for the server</p>
<h2>Restore</h2> <h2>Restore</h2>
<h2>Advanced</h2> <p>A restore in rsync doesn't require any rsync code per-se, as you can just copy individual files from the backup location to the restore location.</p>
<p>Alternatively to restore the entire directory, keeping files that haven't changes, and those that have to the time of the last backup, rsync can do that as below</p>
<pre><code>rsync -auv $BACKUP $RESTORE</code></pre>
<h3>Over the internet</h3>
<p>Like with backups, these restores can be done over the network/internet too</p>
<pre><code>rsync -auv $USER@$HOST:$BACKUP $RESTORE</code></pre>
<h2>Notes/Advanced</h2>
<pre><code>
-r recursive. All files/directories in the path will be backed up
-a archive mode. Recursive, but with file permissions, symlinks, etc retained.
-z compress
-b backups
-R relative
-u update - copy only changed files
-P progress
-c compress
-p preserve permissions
-h human readable. Make the output readible by humans
</code></pre>
<h2>Downsides</h2>
<p>Rsync only keeps one copy of the data, and doesn't keep the changes that were made, making it impossible* to restore a file's contents from the day previous. If this is what you're after, look at <a href="/blog/backup-with-rdiff.html">rdiff-backup</a>.</p>
<p>* Not impossible, as you <em>can</em> set rsync to do this, but it requires a bit of scripting, and isn't as easy as just running the program</p>
</section> </section>
</main> </main>

Loading…
Cancel
Save