mirror cantonese + two more articles
[robinkrens.nl] / docs / backups.html
diff --git a/docs/backups.html b/docs/backups.html
new file mode 100644 (file)
index 0000000..6a40510
--- /dev/null
@@ -0,0 +1,90 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title></title>
+<meta name="generator" content="HTML::TextToHTML v2.51"/>
+<link rel="stylesheet" type="text/css" href="../files/style.css"/>
+</head>
+<body>
+<h1><a name="section_1">Simple Backups</a></h1>
+
+<p>Don't forget to make backups folks! I strongly argue against cloud backup services, because most of the time you have no clue <u>how</u> and <u>where</u> data is being backed up. Besides that, it's really not that hard to do it yourself. If you are not running a server with &gt;1000 people, you would probably just do fine backing up your home directory. 
+</p>
+<h2><a name="section_1_1">How to backup?</a></h2>
+
+<p>A simple backup archive of your home directory: 
+</p>
+<pre>
+        $
+        $ tar --create  --file BACKUP.tar /home/rob
+</pre>
+<p>This creates a so-called <em>tarball</em> of your folder. Data from your home directory is written to BACKUP.tar. If you are not that familiar with linux, this is similar to the famous Windows zip file, but without compression. You might have encountered the <u>tar.gz</u> a few times. This is just like a tarball but compressed. We can add the option --auto-compress to compress. Tar automatically recognizes the extension of the file your are writing the backup to and compresses it accordingly. The first line creates a tar.gz file, the second one writes to a zip file.
+</p>
+<pre>
+        $ tar --create --auto-compress --file BACKUP.tar.gz /home/rob
+        $ tar --create --auto-compress --file BACKUP.zip /home/rob
+</pre>
+<h2><a name="section_1_2">Where to backup?</a></h2>
+<p>Good question. Some options:
+</p>
+<ul>
+  <li>to another folder: if you screw up editing some files in your current working directory
+  </li><li>to another partition: if you screw up your filesystem on your current partition 
+  </li><li>to another drive: if your current drives gets toasted, i.e. mechanical failure. 
+  </li><li>to another computer: if you accidentily burn your house down
+  </li><li>to many other computers, aka the cloud: if you want to make sure your data is backed up, but besides that also saved forever and being spread amongst many places around the world, vulnerable for whatever law is set by those countries.
+</li></ul>
+<p>Option a is similar as the command described above. Just make sure your backup is not in the same folder.
+</p>
+<p>Option b, c are similar to each other. You can also use the option --directory to write the backup file to another partition or (external) hard drive. The following command writes a compressed tarball of my home directory to my external harddrive mounted out /media/externaldrive:
+</p>
+<pre>
+        $ tar --create --auto-compress \
+        --file /media/externalharddrive/BACKUP.tar.gz /home/rob
+</pre>
+<p>Option d. In this case we just simple copy the file (secure ssh copy) to another computer.
+        
+</p><pre>
+        $ tar --create --auto-compress --file BACKUP.tar.gz /home/rob
+        $ scp BACKUP.tar.gz rob@1.2.3.4:/var/backups/
+</pre>
+        
+
+<h2><a name="section_1_3">When to backup?</a></h2>
+<p>Another good question. 
+</p>
+<ul>
+  <li>never
+  </li><li>rarely (or manually)
+  </li><li>scheduled, cronjobs
+  </li><li>on change, inotify
+  </li><li>always
+</li></ul>
+<p>Option b is just manually typing in backup commands a few times a week.
+For option c you can write a simple shell script (i.e. backup.sh) and put it in <u>/etc/cron.daily</u>. For example, the following script would write a daily backup (format like: BACKUP-2019-03-04.tar.gz) to a backup directory
+        
+</p><pre>
+        #!/bin/bash
+        # write full backups to external drive 
+        BACKUP_OF_DIR=/home/rob
+        WRITE_TO_DIR=/media/external
+        DATE=$(date -I)
+
+        # if directory exist, create an archive
+        if [-d $WRITE_TO_DIR ]; then
+                tar --create --auto-compress --file $WRITE_TO_DIR/BACKUP-$DATE.tar.gz 
+        fi
+
+        # remove made backups older than 90 days
+        # TODO
+</pre>
+<p>Option d: TODO
+        
+</p><p>So, option e would be some kind of trojan horse on your computer or device, continuously scanning folders, eating resources and uploading to the cloud.
+</p>
+<h2><a name="section_1_4">Final words</a></h2>
+<p>This article can be viewed as the basics of basics. Of course, there are many other ways to do backups. There are also a few security and performance issues involved. Nonetheless, when and where to backup are equal or even more important.</p>
+
+</body>
+</html>