old-www/LDP/www.debian.org/doc/manuals/system-administrator/ch-sysadmin-backup.html

1275 lines
42 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<title>Debian GNU/Linux System Administrator's Manual (Obsolete Documentation) - Backup and Restore</title>
<link href="index.html" rel="start">
<link href="ch-sysadmin-accounting.html" rel="prev">
<link href="ch-sysadmin-X.html" rel="next">
<link href="index.html#contents" rel="contents">
<link href="index.html#copyright" rel="copyright">
<link href="ch-sysadmin-intro.html" rel="chapter" title="1 Introduction">
<link href="ch-sysadmin-overview.html" rel="chapter" title="2 Overview of a Debian GNU/Linux System">
<link href="ch-sysadmin-files.html" rel="chapter" title="3 Files and Devices">
<link href="ch4.html" rel="chapter" title="4 Programs and processes">
<link href="ch-sysadmin-directories.html" rel="chapter" title="5 Directory Structure">
<link href="ch-sysadmin-filesystems.html" rel="chapter" title="6 Filesystems and Storage Media">
<link href="ch-sysadmin-booting.html" rel="chapter" title="7 Boot and Shutdown">
<link href="ch-sysadmin-users.html" rel="chapter" title="8 Managing User Accounts">
<link href="ch-sysadmin-sessions.html" rel="chapter" title="9 Logging In and Out">
<link href="ch-sysadmin-printing.html" rel="chapter" title="10 Printing">
<link href="ch-sysadmin-accounting.html" rel="chapter" title="11 Accounting">
<link href="ch-sysadmin-backup.html" rel="chapter" title="12 Backup and Restore">
<link href="ch-sysadmin-X.html" rel="chapter" title="13 X Windows">
<link href="ch-sysadmin-security.html" rel="chapter" title="14 Security">
<link href="ch-sysadmin-config.html" rel="chapter" title="15 System Configuration">
<link href="ch-sysadmin-time.html" rel="chapter" title="16 Time">
<link href="ch-sysadmin-localisation.html" rel="chapter" title="17 Localisation">
<link href="ch-sysadmin-index.html" rel="chapter" title="18 Index">
<link href="ch-sysadmin-intro.html#s1.1" rel="section" title="1.1 About this manual">
<link href="ch-sysadmin-intro.html#s1.2" rel="section" title="1.2 Where to find newer versions">
<link href="ch-sysadmin-intro.html#s1.3" rel="section" title="1.3 Comments">
<link href="ch-sysadmin-overview.html#s2.1" rel="section" title="2.1 The main components of a system">
<link href="ch-sysadmin-files.html#s3.1" rel="section" title="3.1 Files">
<link href="ch-sysadmin-files.html#s3.2" rel="section" title="3.2 Devices">
<link href="ch4.html#s4.1" rel="section" title="4.1 Programs">
<link href="ch4.html#s4.2" rel="section" title="4.2 Processes">
<link href="ch4.html#s4.3" rel="section" title="4.3 The /proc filesystem">
<link href="ch4.html#s4.4" rel="section" title="4.4 Tools for handling programs and processes">
<link href="ch-sysadmin-directories.html#s5.1" rel="section" title="5.1 Directories">
<link href="ch-sysadmin-directories.html#s5.2" rel="section" title="5.2 Permissions">
<link href="ch-sysadmin-directories.html#s5.3" rel="section" title="5.3 Links">
<link href="ch-sysadmin-directories.html#s5.4" rel="section" title="5.4 ACL - Access Control Lists">
<link href="ch-sysadmin-directories.html#s5.5" rel="section" title="5.5 Tools for managing directories">
<link href="ch-sysadmin-filesystems.html#s6.1" rel="section" title="6.1 Storage devices and media">
<link href="ch-sysadmin-filesystems.html#s6.2" rel="section" title="6.2 Types of filesystem">
<link href="ch-sysadmin-filesystems.html#s6.3" rel="section" title="6.3 Quotas">
<link href="ch-sysadmin-filesystems.html#s6.4" rel="section" title="6.4 Tools for managing filesystems">
<link href="ch-sysadmin-booting.html#s7.1" rel="section" title="7.1 Boot loaders">
<link href="ch-sysadmin-users.html#s8.1" rel="section" title="8.1 Concepts">
<link href="ch-sysadmin-users.html#s8.2" rel="section" title="8.2 Common tasks">
<link href="ch-sysadmin-users.html#s8.3" rel="section" title="8.3 Tools reference">
<link href="ch-sysadmin-users.html#s8.4" rel="section" title="8.4 Files reference">
<link href="ch-sysadmin-sessions.html#s9.1" rel="section" title="9.1 Starting a session - logging in">
<link href="ch-sysadmin-printing.html#s10.1" rel="section" title="10.1 Print devices">
<link href="ch-sysadmin-printing.html#s10.2" rel="section" title="10.2 Spooler">
<link href="ch-sysadmin-accounting.html#s11.1" rel="section" title="11.1 Concepts">
<link href="ch-sysadmin-backup.html#s12.1" rel="section" title="12.1 Why backup?">
<link href="ch-sysadmin-backup.html#s12.2" rel="section" title="12.2 What to backup?">
<link href="ch-sysadmin-backup.html#s12.3" rel="section" title="12.3 Backup devices and media">
<link href="ch-sysadmin-backup.html#s12.4" rel="section" title="12.4 Backup methods and software">
<link href="ch-sysadmin-backup.html#s12.5" rel="section" title="12.5 Types of backup">
<link href="ch-sysadmin-X.html#s13.1" rel="section" title="13.1 Overview of X">
<link href="ch-sysadmin-security.html#s14.1" rel="section" title="14.1 Threats">
<link href="ch-sysadmin-config.html#s15.1" rel="section" title="15.1 ???">
<link href="ch-sysadmin-time.html#s16.1" rel="section" title="16.1 Setting time, time zones and Daylight Saving">
<link href="ch-sysadmin-time.html#s16.2" rel="section" title="16.2 Setting and showing hardware clock">
<link href="ch-sysadmin-time.html#s-multiboot-with" rel="section" title="16.3 Multiboot with operating systems not understanding timezone">
<link href="ch-sysadmin-time.html#s-syncing-time" rel="section" title="16.4 Syncing time, rdate and NTP">
<link href="ch-sysadmin-time.html#s16.5" rel="section" title="16.5 Setting up an NTP server">
<link href="ch-sysadmin-time.html#s-radio-clocks" rel="section" title="16.6 Radio clocks">
<link href="ch-sysadmin-time.html#s16.7" rel="section" title="16.7 Timestamps">
<link href="ch-sysadmin-time.html#s16.8" rel="section" title="16.8 Time in cron">
<link href="ch-sysadmin-localisation.html#s17.1" rel="section" title="17.1 Environment variables">
<link href="ch-sysadmin-overview.html#s2.1.1" rel="subsection" title="2.1.1 The hardware">
<link href="ch-sysadmin-overview.html#s2.1.2" rel="subsection" title="2.1.2 The Linux kernel">
<link href="ch-sysadmin-overview.html#s2.1.3" rel="subsection" title="2.1.3 Devices">
<link href="ch-sysadmin-overview.html#s2.1.4" rel="subsection" title="2.1.4 Filesystems">
<link href="ch-sysadmin-files.html#s3.1.1" rel="subsection" title="3.1.1 Concepts">
<link href="ch-sysadmin-files.html#s3.1.2" rel="subsection" title="3.1.2 Inodes">
<link href="ch-sysadmin-files.html#s3.1.3" rel="subsection" title="3.1.3 Links">
<link href="ch-sysadmin-files.html#s3.1.4" rel="subsection" title="3.1.4 Permissions">
<link href="ch-sysadmin-files.html#s3.2.1" rel="subsection" title="3.2.1 Device drivers">
<link href="ch-sysadmin-files.html#s3.2.2" rel="subsection" title="3.2.2 Device nodes">
<link href="ch-sysadmin-files.html#s3.2.3" rel="subsection" title="3.2.3 Kernel modules">
<link href="ch-sysadmin-directories.html#s5.3.1" rel="subsection" title="5.3.1 Hard links">
<link href="ch-sysadmin-directories.html#s5.3.2" rel="subsection" title="5.3.2 Symbolic links">
<link href="ch-sysadmin-users.html#s8.1.1" rel="subsection" title="8.1.1 Usernames and User IDs">
<link href="ch-sysadmin-users.html#s8.1.2" rel="subsection" title="8.1.2 Groups and Group IDs">
<link href="ch-sysadmin-users.html#s8.1.3" rel="subsection" title="8.1.3 Passwords">
<link href="ch-sysadmin-users.html#s8.1.4" rel="subsection" title="8.1.4 Quotas">
<link href="ch-sysadmin-users.html#s8.2.1" rel="subsection" title="8.2.1 Adding new users">
<link href="ch-sysadmin-users.html#s8.2.2" rel="subsection" title="8.2.2 Changing or editing user information and settings">
<link href="ch-sysadmin-users.html#s8.2.3" rel="subsection" title="8.2.3 Removing user accounts">
<link href="ch-sysadmin-users.html#s8.2.4" rel="subsection" title="8.2.4 Changing user passwords">
<link href="ch-sysadmin-users.html#s8.2.5" rel="subsection" title="8.2.5 Setting and changing password expiry times">
<link href="ch-sysadmin-users.html#s8.2.6" rel="subsection" title="8.2.6 Creating groups">
<link href="ch-sysadmin-users.html#s8.2.7" rel="subsection" title="8.2.7 Editing groups">
<link href="ch-sysadmin-users.html#s8.2.8" rel="subsection" title="8.2.8 Deleting groups">
<link href="ch-sysadmin-users.html#s8.2.9" rel="subsection" title="8.2.9 Setting up quotas">
<link href="ch-sysadmin-users.html#s8.2.10" rel="subsection" title="8.2.10 Using shadow passwords">
<link href="ch-sysadmin-users.html#s8.3.1" rel="subsection" title="8.3.1 Command-line tools">
<link href="ch-sysadmin-users.html#s8.3.1.1" rel="subsection" title="8.3.1.1 adduser, addgroup">
<link href="ch-sysadmin-users.html#s8.3.1.2" rel="subsection" title="8.3.1.2 chage">
<link href="ch-sysadmin-users.html#s8.3.1.3" rel="subsection" title="8.3.1.3 chfn">
<link href="ch-sysadmin-users.html#s8.3.1.4" rel="subsection" title="8.3.1.4 chsh">
<link href="ch-sysadmin-users.html#s8.3.1.5" rel="subsection" title="8.3.1.5 passwd">
<link href="ch-sysadmin-users.html#s8.3.1.6" rel="subsection" title="8.3.1.6 userdel">
<link href="ch-sysadmin-users.html#s8.3.1.7" rel="subsection" title="8.3.1.7 vipw, vigr">
<link href="ch-sysadmin-users.html#s8.3.2" rel="subsection" title="8.3.2 Graphical tools">
<link href="ch-sysadmin-users.html#s8.4.1" rel="subsection" title="8.4.1 /etc/passwd">
<link href="ch-sysadmin-users.html#s8.4.2" rel="subsection" title="8.4.2 /etc/group">
<link href="ch-sysadmin-users.html#s8.4.3" rel="subsection" title="8.4.3 /etc/shadow">
<link href="ch-sysadmin-printing.html#s10.2.1" rel="subsection" title="10.2.1 Lp">
<link href="ch-sysadmin-printing.html#s10.2.2" rel="subsection" title="10.2.2 LPrng">
<link href="ch-sysadmin-backup.html#s-sect-floppy" rel="subsection" title="12.3.1 Floppy">
<link href="ch-sysadmin-backup.html#s12.3.1.1" rel="subsection" title="12.3.1.1 Backup example 1, suitable for disk media">
<link href="ch-sysadmin-backup.html#s12.3.1.2" rel="subsection" title="12.3.1.2 Backup example 2, suitable for tape media">
<link href="ch-sysadmin-backup.html#s12.3.1.3" rel="subsection" title="12.3.1.3 Backup example 3, suitable for disk media with DOS file system">
<link href="ch-sysadmin-backup.html#s12.3.2" rel="subsection" title="12.3.2 High Capacity Floppies">
<link href="ch-sysadmin-backup.html#s12.3.3" rel="subsection" title="12.3.3 CD-R and CD-RW">
<link href="ch-sysadmin-backup.html#s12.3.4" rel="subsection" title="12.3.4 Tapes">
<link href="ch-sysadmin-backup.html#s12.4.1" rel="subsection" title="12.4.1 Network backups">
<link href="ch-sysadmin-backup.html#s12.4.1.1" rel="subsection" title="12.4.1.1 Installing EMC NetWorker Client">
<link href="ch-sysadmin-backup.html#s12.4.1.2" rel="subsection" title="12.4.1.2 Setting up and Configuring">
<link href="ch-sysadmin-backup.html#s12.4.2" rel="subsection" title="12.4.2 Tar et al">
<link href="ch-sysadmin-backup.html#s12.4.3" rel="subsection" title="12.4.3 Backup software">
<link href="ch-sysadmin-time.html#s-tzconfig" rel="subsection" title="16.1.1 Changing the timezone after installation">
<link href="ch-sysadmin-time.html#s16.1.2" rel="subsection" title="16.1.2 Setting the TZ environment variable.">
<link href="ch-sysadmin-time.html#s16.4.1" rel="subsection" title="16.4.1 Setting time at system boot">
<link href="ch-sysadmin-time.html#s16.4.2" rel="subsection" title="16.4.2 Setting time using NTP">
<link href="ch-sysadmin-time.html#s16.4.3" rel="subsection" title="16.4.3 Other methods">
</head>
<body>
<p><a name="ch-sysadmin-backup"></a></p>
<hr>
<p>
[ <a href="ch-sysadmin-accounting.html">previous</a> ]
[ <a href="index.html#contents">Contents</a> ]
[ <a href="ch-sysadmin-intro.html">1</a> ]
[ <a href="ch-sysadmin-overview.html">2</a> ]
[ <a href="ch-sysadmin-files.html">3</a> ]
[ <a href="ch4.html">4</a> ]
[ <a href="ch-sysadmin-directories.html">5</a> ]
[ <a href="ch-sysadmin-filesystems.html">6</a> ]
[ <a href="ch-sysadmin-booting.html">7</a> ]
[ <a href="ch-sysadmin-users.html">8</a> ]
[ <a href="ch-sysadmin-sessions.html">9</a> ]
[ <a href="ch-sysadmin-printing.html">10</a> ]
[ <a href="ch-sysadmin-accounting.html">11</a> ]
[ 12 ]
[ <a href="ch-sysadmin-X.html">13</a> ]
[ <a href="ch-sysadmin-security.html">14</a> ]
[ <a href="ch-sysadmin-config.html">15</a> ]
[ <a href="ch-sysadmin-time.html">16</a> ]
[ <a href="ch-sysadmin-localisation.html">17</a> ]
[ <a href="ch-sysadmin-index.html">18</a> ]
[ <a href="ch-sysadmin-X.html">next</a> ]
</p>
<hr>
<h1>
Debian GNU/Linux System Administrator's Manual (Obsolete Documentation)
<br>Chapter 12 - Backup and Restore
</h1>
<hr>
<p>
author = Tapio Lehtonen
</p>
<p>
topics = why backup, what to backup, how to backup, backup devices and media
</p>
<hr>
<h2><a name="s12.1"></a>12.1 Why backup?</h2>
<p>
Backups are needed in case a file or a group of files is lost. The reasons for
losing files include
</p>
<ul>
<li>
<p>
Hardware failure like disk breaking,
</p>
</li>
</ul>
<ul>
<li>
<p>
accidentally deleting wrong file and
</p>
</li>
</ul>
<ul>
<li>
<p>
computer being stolen.
</p>
</li>
</ul>
<p>
Backups help in all the above situations. In addition, it may be good to have
access to older versions of files, for example a configuration file worked a
week ago, but since then it has been changed and nobody remembers how, its just
not working anymore.
</p>
<p>
There are other solutions, and they are good to have if you can afford them.
These include
</p>
<ul>
<li>
<p>
redundant disks (RAID 1 or 5), so that one disk can break without loss of data,
</p>
</li>
</ul>
<ul>
<li>
<p>
using an undelete system (or not making mistakes when deleting files :-) and
</p>
</li>
</ul>
<ul>
<li>
<p>
locking up computers.
</p>
</li>
</ul>
<p>
These help, but if there is anything you do not want to lose on the computer,
<strong>make sure there are backups and they can be restored.</strong>
</p>
<p>
This chapter is more of a general nature than the others, which are specific to
the Debian GNU/Linux. There are so many different backup devices and backup
software, that it is difficult to go into details without assuming for example
a SCSI tape drive and GNU <code>tar</code> used to write backups. Chapter <a
href="#s-sect-floppy">Floppy, Section 12.3.1</a> gives three detailed examples,
use them as a guide in doing backups to other kinds of media.
</p>
<hr>
<h2><a name="s12.2"></a>12.2 What to backup?</h2>
<p>
If there is room on the backup media, and time limits permit running backups
long enough, it probably is wisest to back up everything. You may skip
<code>/tmp</code> or other places where it is known there are only temporary
files that nobody wants to backup.
</p>
<p>
If space or time limits place restrictions, consider not backing up the
following:
</p>
<ul>
<li>
<p>
Files that come directly from a CD or other removable media. It may even be
faster to copy them again from CD than restoring from backup media.
</p>
</li>
</ul>
<ul>
<li>
<p>
Files that can be regenerated easily. For example, object files that can be
made with <code>make</code>. Just make sure all the source files and compilers
are backed up.
</p>
</li>
</ul>
<ul>
<li>
<p>
If the Internet connection is fast, it may be easy enough to download files
again. Just keep a list of the files and where to download them from.
</p>
</li>
</ul>
<hr>
<h2><a name="s12.3"></a>12.3 Backup devices and media</h2>
<p>
You need some media to store the backups. It is preferable to use removable
media, to store the backups away from the computer and to get
&quot;unlimited&quot; storage for backups.
</p>
<p>
If the backups are on-line, they can be wiped out by mistake. If the backups
are on the same disk as the original data, they do not help at all if the disk
fails and is not readable anymore. If the backup media is cheap, it is
possible to take a backup every day and store them indefinitely.
</p>
<p>
The following subsections discuss different kinds of backup media. As a
hands-on example, a floppy is used to back up directory trees in different
ways. Use these examples as a guideline when using other medias.
</p>
<hr>
<h3><a name="s-sect-floppy"></a>12.3.1 Floppy</h3>
<p>
Floppy disks are cheap, and on PC computers there usually is a floppy disk
drive. On the other hand, it is not very fast to write to a floppy, and the
capacity of 1.4MBytes is not very much. If the backup does not fit on one
media, taking backups becomes an arduous task, what with having to stand by and
change the media every now and then.
</p>
<p>
However, if the data to be backed up fits in one floppy, they are a reasonable
alternative. Compressing the data usually means it uses about 50% of the
original size. Thus, you can expect to get almost 3MBytes to one 1.4M floppy
disk with compression.
</p>
<p>
Examples use <code>tar</code>, because it is available on almost all Unix
versions and also on some other operating systems, it can preserve file
ownerships and date stamps and write directly to device or to a file.
</p>
<p>
There are different ways to use the floppy with <code>tar</code>:
</p>
<ol type="1" start="1" >
<li>
<p>
Create a Linux filesystem on the floppy, mount, write like to any Linux disk
and unmount the floppy,
</p>
</li>
</ol>
<ol type="1" start="2" >
<li>
<p>
write directly to the device <code>/dev/fd0</code> and
</p>
</li>
</ol>
<ol type="1" start="3" >
<li>
<p>
use the floppy with DOS file system, and copy the tar file there with
<code>mcopy</code> (see info file mtools with command <code>info
mtools</code>).
</p>
</li>
</ol>
<p>
These three methods correspond to three different classes of media:
</p>
<ol type="1" start="1" >
<li>
<p>
Random access or direct access, mostly disks. The media is like any disk or
directory tree, it is possible to do <code>ls</code>, <code>cp</code> and other
commands accessing files. It is easy to restore one file from the backup media
by simply copying it back.
</p>
</li>
</ol>
<ol type="1" start="2" >
<li>
<p>
Serial access, like a tape drive. Reading or writing the media starts from the
beginning and goes to the end. It is not possible to start directly in the
middle.
</p>
</li>
</ol>
<ol type="1" start="3" >
<li>
<p>
Media that is a DOS file system. This is readable on all kinds of operating
system, which is useful if you need to read the backup on some other kind of
computer.
</p>
</li>
</ol>
<hr>
<h4><a name="s12.3.1.1"></a>12.3.1.1 Backup example 1, suitable for disk media</h4>
<p>
Here is an example to backup the <code>~/Work/Debian-doc</code> directory tree
to floppy. First check how large the directory tree is:
</p>
<pre>
$ cd ~/Work
tale@dilbert ~/Work
$ du -sk Debian-doc
1005 Debian-doc
tale@dilbert ~/Work
$
</pre>
<p>
This shows 1.005MBytes, so it should fit on one floppy.
</p>
<p>
This example uses the floppy as removable media with Linux filesystem.
</p>
<p>
Now a minix filesystem is created on the floppy. This is the filesystem Linux
uses for floppies and other small media. Note, that all data on the media is
lost when it is formatted. The first floppy drive is device
<code>/dev/fd0</code>.
</p>
<pre>
dilbert# mkfs -t minix -c /dev/fd0 1440
480 inodes
1440 blocks
Firstdatazone=19 (19)
Zonesize=1024
Maxsize=268966912
160 ...320 ...480 ...640 ...800 ...960 ...1120 ...1296 ...dilbert#
</pre>
<p>
Now the floppy disk is mounted and backup is run and tested. Note, that the
mount point <code>/A</code> must already exist (see <code>mount(8)</code>. To
allow an ordinary user <code>tale</code> write access to the filesystem on this
floppy, the owner and group owner are changed.
</p>
<pre>
dilbert# mount -t minix /dev/fd0 /A
dilbert# chown tale.tale /A
dilbert# ls -ld /A
drwxr-xr-x 3 tale tale 1024 Dec 3 21:21 /A
dilbert#
</pre>
<p>
It is useful the check the floppy is mounted and there is available space, for
example with command <code>df</code>.
</p>
<pre>
$ df -h
Filesystem Size Used Avail Capacity Mounted on
/dev/sda5 99M 22M 72M 23% /
/dev/sda6 964M 565M 349M 62% /usr
/dev/sda7 190M 33M 147M 18% /var
/dev/sda8 2.7G 1.3G 1.2G 53% /export
/dev/sdb2 3.8G 2.4G 1.3G 65% /export2
dilbert:/export/home 2.7G 1.3G 1.2G 53% /amd/dilbert/export/home
/dev/fd0 1.4M 1.0K 1.4M 0% /A
tale@dilbert ~/Work
$
</pre>
<p>
Now <code>tar</code> is used to copy the whole directory tree to the floppy.
It is better to use <code>tar</code>, it preserves file ownerships and
permissions. If you try to use <code>cp -r</code> you will notice the backup
is not identical.
</p>
<pre>
$ cd Work
tale@dilbert ~/Work
$ tar cf - ./Debian-doc | ( cd /A ; tar xpBf - )
tale@dilbert ~/Work
$ ls -l /A
total 1
drwxr-xr-x 6 tale 232 320 Dec 3 20:41 Debian-doc
tale@dilbert ~/Work
$
</pre>
<p>
You can also do <code>ls -lR /A</code> to see that all the files are there.
</p>
<p>
Here we restore the backup to <code>/tmp/Debian-doc</code>.
</p>
<pre>
$ cd /A
tale@dilbert /A
$ ls -l
total 1
drwxr-xr-x 6 tale 232 320 Dec 3 20:41 Debian-doc
tale@dilbert /A
$ tar cf - ./Debian-doc | ( cd /tmp ; tar xpBf - )
tale@dilbert /tmp
$ ls -l
total 7512
drwxr-xr-x 6 tale tale 1024 Dec 3 20:41 Debian-doc
-rw------- 1 root root 599648 Dec 3 22:25 foo.foo
drwx------ 2 tale tale 1024 Dec 2 20:58 orbit-tale
-rw-rw---- 1 tale tale 4054572 Nov 24 21:53 tale
tale@dilbert /tmp
$ du --summarize --kilobytes Debian-doc/
1005 Debian-doc
tale@dilbert /tmp
$
</pre>
<p>
It looks like the backup is on the floppy and we could even read it back. It
is worth checking your backup method works, and the backup can indeed be
restored.
</p>
<p>
The next command unmounts the floppy. This is <strong>very
important!</strong>. If you mount a removable media, it <strong>must be
unmounted</strong> before it is removed from the drive.
</p>
<pre>
dilbert# umount /A
dilbert#
</pre>
<p>
The above method is usable with other kinds of removable disk drives, for
example high capacity floppies.
</p>
<hr>
<h4><a name="s12.3.1.2"></a>12.3.1.2 Backup example 2, suitable for tape media</h4>
<p>
As another example, we backup <code>/etc</code> directly to the
<code>/dev/fd0</code> device:
</p>
<pre>
dilbert# cd /
dilbert# tar czf /dev/fd0 ./etc
dilbert# tar tzf /dev/fd0 | head
./etc/
./etc/modules
./etc/xemacs/
./etc/xemacs/site-start-19.d/
./etc/xemacs/site-start-19.d/50dpkg-dev.el
./etc/init.d/
./etc/init.d/network
./etc/init.d/modutils
./etc/init.d/kerneld
./etc/init.d/kdm
Broken pipe
dilbert#
</pre>
<p>
We could read the listing (option <code>t</code> for <code>tar</code>) from the
floppy, so we can assume the backup is OK. Note, that if you plan to read this
floppy back later, <strong>make sure you remember how the floppy was
written</strong>. If you forget it was written with <code>tar</code> and with
compression, you spend a lot of time figuring it out. This same applies to all
media that you store for any longer period of time, and especially if you send
the media to someone else.
</p>
<p>
The above method is usable also with tape drives. Replace the device name
<code>/dev/fd0</code> with device name for the tape drive, and you can use
<code>tar</code> as Tape ARchiver.
</p>
<hr>
<h4><a name="s12.3.1.3"></a>12.3.1.3 Backup example 3, suitable for disk media with DOS file system</h4>
<p>
If you have or want to use DOS formatted floppy disks, it is possible to use
them like in example 1, mount them with flag <code>-t msdos</code> to inform
the <code>mount</code> command. But in this example, we us DOS floppies with
the <code>mtools</code> -commands.
</p>
<p>
The backup is not written directly to floppy, it is first created on
<code>/tmp</code> directory and copied from there to floppy with command
<code>mcopy</code>. For more information, use <code>info mtools</code>.
</p>
<pre>
$ pwd
/amd/dilbert/export/home/tale/Work
tale@dilbert /amd/dilbert/export/home/tale/Work
$ du -sk Debian-doc
2399 Debian-doc
tale@dilbert /amd/dilbert/export/home/tale/Work
$ tar czf /tmp/Debian-doc.tgz ./Debian-doc
tale@dilbert /amd/dilbert/export/home/tale/Work
$ ls -l /tmp/Debian-doc.tgz
-rw-rw-r-- 1 tale tale 609296 Dec 5 04:56 /tmp/Debian-doc.tgz
tale@dilbert /amd/dilbert/export/home/tale/Work
$ mcopy /tmp/Debian-doc.tgz a:
tale@dilbert /amd/dilbert/export/home/tale/Work
$ mdir a:
Volume in drive A is LINUX BOOT
Volume Serial Number is 2410-07EF
Directory for A:/
DEBIAN~1 TGZ 609296 12-05-1998 4:58 Debian-doc.tgz
1 file 609 296 bytes
847 872 bytes free
tale@dilbert /amd/dilbert/export/home/tale/Work
$
</pre>
<p>
This method can be used when the backup needs to be read back on some other
computer, not necessarily running Linux. This is also useful for sending files
to some poor soul not running Linux. In this case, it is better not to use
<code>tar</code>, programs like <code>zip</code>, <code>gzip</code> and
<code>zoo</code> are available on most operating systems.
</p>
<hr>
<h3><a name="s12.3.2"></a>12.3.2 High Capacity Floppies</h3>
<p>
High capacity floppies are
</p>
<ul>
<li>
<p>
<code><a href="http://www.iomega.com/product/zip">Iomega Zip-drive</a></code>,
</p>
</li>
</ul>
<ul>
<li>
<p>
<code><a href="http://www.superdisk.com/">LS-120</a></code>, <code><a
href="http://www.winstation.com/main.html">LS-120</a></code>,
</p>
</li>
</ul>
<ul>
<li>
<p>
<code><a href="http://www.sony.com/HiFD">Sony HiFD</a></code>,
</p>
</li>
</ul>
<p>
All of these are about floppy disk size, store 100MBytes to 200MBytes and are
faster and more expensive than floppy drives. They are connected to EIDE port,
Parallel port, SCSI or USB. LS-120 and Sony SuperFloppy can read and write
ordinary 1.4MByte floppy disks.
</p>
<p>
You can use these things like in the above examples where a floppy disk was
used, but you have to install the devices and the device driver software before
they can be used. Then the device name depends on what kind of connection the
thing uses.
</p>
<p>
There is more info on using the above high capacity floppies on Linux in the
HOWTO documents. (reference to HOWTOs???)
</p>
<p>
<strong>Somebody with experience from the above devices: please confirm my
guessing above or send info on how they can be used.</strong>
</p>
<hr>
<h3><a name="s12.3.3"></a>12.3.3 CD-R and CD-RW</h3>
<p>
Meta: Capacity &lt;= 640MBytes, speed 150 -- 600KBits/sek. Special software
needed to burn the CD. DVD-RAM
</p>
<p>
CD writers can be used as backup devices. Writable CD media is either writable
exactly once (CD-R), or erasable and rewritable (CD-RW). CD-R disks can be
read on ordinary CD drives, but CD-RW disks need Multi-Read capability from the
reader. This is good to know if you plan to read the CD back on some other
computer.
</p>
<p>
Assuming the CD writer is installed and configured correctly, and you have the
necessary software to write to the CD, taking backups is best done with the
first method in the floppy disk example above, i.e. creating a Linux file
system on the CD. Since the CD is a disk, i.e. a random access device, using
it this way is easy. Just mount it and copy files or whole directory trees
there.
</p>
<p>
Restoring is also straightforward, since the CD can be examined with ordinary
file system commands like <code>ls</code>, and it is easy to copy a single file
back. You can also compare the files in the backup to files in hard disk with
<code>diff</code> for example.
</p>
<p>
Problems with CD-R are their write once -nature. They need to be written all
in one go, and then closed. After closing, it is not possible to modify the
CD, so if there is something wrong there it has to be thrown away.
</p>
<p>
CD-RW can be erased, but my understanding is the whole disk must be erased. In
addition, looks like formatting a CD-RW takes about one hour.
</p>
<p>
Looks like the program to write CD's is X-CD-Roast, available as Debian
GNU/Linux package <code>xcdroast</code>. More information from <code><a
href="http://www.fh-muenchen.de/home/ze/rz/services/projects/xcdroast/e_overview.html">X-CD-Roast
Webpage</a></code>
</p>
<hr>
<h3><a name="s12.3.4"></a>12.3.4 Tapes</h3>
<p>
Meta: Popular backup media. Wide range of speeds, capacities and cost.
</p>
<p>
Tape drives are popular backup devices. The media is relatively cheap per
gigabyte, and tape capacities go up to several tens of gigabytes. On the other
hand, the tape drives may be expensive and write speeds slower than disks.
</p>
<p>
Tape drives with SCSI connector should work with Linux. So called floppy tape
drives that connect to the floppy disk interface may work if the ftape driver
supports the particular model.
</p>
<p>
Writing to SCSI tape drives goes like in example 2 in floppy disk chapter.
</p>
<p>
I'm not sure about floppy tapes, have to read the ftape docs.
</p>
<hr>
<h2><a name="s12.4"></a>12.4 Backup methods and software</h2>
<p>
Backup methods include simply copying files to another media, using dd, tar or
similar program to create an archive and using special backup programs.
</p>
<hr>
<h3><a name="s12.4.1"></a>12.4.1 Network backups</h3>
<p>
In an enterprise environment there may be a backup server running some network
backup software. If there are GNU/Linux clients available for that software,
its possible to install them, configure the client machine on the backup server
and start taking backups over the network. This is a low cost solution. If
the backup server is already there, GNU/Linux clients are sometimes free to
download.
</p>
<hr>
<h4><a name="s12.4.1.1"></a>12.4.1.1 Installing EMC NetWorker Client</h4>
<p>
<code><a
href="http://software.emc.com/products/product_family/networker_family.htm">EMC
NetWorker</a></code> is a backup system formerly known as Legato. EMC supplies
NetWorker Client for GNU/Linux, but with almost no technical support. The
applications are available in RPM binary packages from the <code><a
href="ftp://ftp.legato.com/pub/support">Legato FTP Site</a></code>. The
tarball will uncompress to several RPM packages. A system that will only send
files to the backup server will need <code>lgtoclnt-7.3-1.i686.rpm</code> and
<code>lgtoman-7.3-1.i686.rpm</code>.
</p>
<p>
The client package will allow the backup server to connect to your system and
to request the files that need to be backup to. The configuration is almost
all done on the backup server. The client system only need to know which
backup server to allow. Your contract should allow you install the client
packages on your system as long as you have the server licence but please check
with your EMC representative if you have doubts.
</p>
<p>
To install these packages on a Debian GNU/Linux system, they must be converted
to Debian .deb format. The files supplied by Legato are relocatable
<samp>.rpm</samp> files, and <code>alien</code> version 6.27 and smaller can
not correctly convert these. Use <code>alien</code> version 6.28 or later.
</p>
<p>
Converting the packages goes like this:
</p>
<pre>
vendredi:/tmp# alien --to-deb lgtoclnt-7.3-1.i686.rpm
lgtoclnt_7.3-2_i386.deb generated
vendredi:/tmp# alien --to-deb lgtoman-7.3-1.i686.rpm
lgtoman_7.3-2_i386.deb generated
</pre>
<p>
You can then install the packages like this
</p>
<pre>
# dpkg --install lgtoclnt-7.3-1.i686.deb
# dpkg --install lgtoman-7.3-1.i686.deb
</pre>
<p>
The conversion from RPMs is not perfect and you will have to perform a few
steps by hand to have everything running.
</p>
<hr>
<h4><a name="s12.4.1.2"></a>12.4.1.2 Setting up and Configuring</h4>
<p>
To get backups with Legato, there must be <code>nsrexecd</code> running on the
backup client host. This process communicates with the Legato server. On a
client only system, other Legato prosesses are not needed,
<code>nsrexecd</code> starts them as needed.
</p>
<p>
You need to tell <code>nsrexecd</code> from which backup server it can accept
connection. This can be done from the command line or from a resource file.
The preferred way is from a resource file:
</p>
<pre>
# mkdir -p /nsr/res
# echo &quot;backup-server.example.com&quot; &gt; /nsr/res/servers
# echo &quot;other.example.net&quot; &gt;&gt; /nsr/res/servers
</pre>
<p>
Note that NetWorker uses a non lsb compliant directory <code>/nsr/</code>.
There is no documented way to tell it to look in <code>/etc/</code>.
</p>
<p>
If you are using a firewall, you need to open the NetWorker ports. NetWorker
uses remote procedure calls based on Sun RPCs with its own portmapper. You
need to open the portmapper ports (7937:7938) and the RPC port range
(10001:10100). With shorewall you would do it by putting those rules in
<code>/etc/shorewall/rules</code>
</p>
<pre>
# EMC NetWorker (Backups)
ACCEPT net fw udp 7937:7938
ACCEPT net fw tcp 7937:7938
ACCEPT net fw tcp 10001:10100
</pre>
<p>
To check the installation, start <code>nsrexecd</code> manually, check that it
is running and test what the backup server can do with this new client.
</p>
<pre>
vendredi:/tmp/Legato# /usr/sbin/nsrexecd
vendredi:/tmp/Legato# ps aux | grep nsr
root 4031 0.5 0.6 1132 768 ? S 15:48 0:00 /usr/sbin/nsrexecd
root 4033 0.0 0.2 848 344 p2 S 15:48 0:00 grep nsr
vendredi:/tmp/Legato#
</pre>
<p>
Next go to the backup server, and do a test run, where nothing is actually
saved to tape, but Legato server contacts the client and probes the file
systems. This way you can check most of the functionality and can see what
Legato would do when started for real.
</p>
<pre>
root@lehmus:/# savegrp -n -p -v -P hplp -c vendredi Linux_Clients
vendredi:All level=incr
01/21/99 16:26:17 savegrp: Run up to 12 clients in parallel
01/21/99 16:26:17 savegrp: vendredi:probe started
savefs -s lehmus -g Linux_Clients -p -n -l full -R -v
01/21/99 16:26:20 savegrp: vendredi:probe succeeded.
rcmd vendredi, user root: `savefs -s lehmus -g Linux_Clients -p -n -l full -R -v'
nsrexec: authtype nsrexec
type: NSR client description;
pools supported: Yes;
remote user: root;
groups: daemon, root, bin, sys, adm, tty, disk, lp, mail, news, daemon;
arch: i586;
client OS type: Linux;
CPUs: 1;
IP address: 172.19.13.36;
machine type: desktop;
MB used: 828;
NetWorker version: Utah.Build.MJFeral_8_11_98_SNAP;
OS: Linux 2.0.34;
version: Utah.Build.MJFeral_8_11_98_SNAP;
save set: path=/, level=full, diskno=0, max_sessions=3, stype=save,\
path=/var, level=full, diskno=0, max_sessions=3, stype=save,\
path=/export/home, level=full, diskno=0, max_sessions=3, stype=save ;
parallelism: 8
--- Probe Summary ---
vendredi:/ level=full, dn=0, mx=3, vers=pools, p=4
vendredi:/ level=full, pool=SMT Workstation, save as of Thu Jan 1 03:00:00 GMT+0300 1970
vendredi:/var level=full, dn=0, mx=3, vers=pools, p=4
vendredi:/var level=full, pool=SMT Workstation, save as of Thu Jan 1 03:00:00 GMT+0300 1970
vendredi:/export/home level=full, dn=0, mx=3, vers=pools, p=4
vendredi:/export/home level=full, pool=SMT Workstation, save as of Thu Jan 1 03:00:00 GMT+0300 1970
vendredi:index level=full, dn=-1, mx=0, vers=pools, p=4
vendredi:index level=full, pool=SMT Workstation, save as of Thu Jan 1 03:00:00 GMT+0300 1970
root@lehmus:/#
</pre>
<p>
If the previous tests looked OK, you can set up automatic backups on the server
(or ask the backup administrator to do it).
</p>
<p>
The remaining configuration on the Linux host is to add starting of
<code>nsrexecd</code> to the boot scripts, for example like this:
</p>
<pre>
#! /bin/sh
#
# Script to start EMC Networker backup daemon
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/nsrexecd
NAME=nsrexecd
DESC=&quot;legato backup daemon&quot;
NICE=15
test -f $DAEMON || exit 0
set -e
case &quot;$1&quot; in
start)
echo -n &quot;Starting $DESC: $NAME&quot;
start-stop-daemon --start -N $NICE -o --exec $DAEMON
echo &quot;.&quot;
;;
stop)
echo -n &quot;Stopping $DESC: $NAME&quot;
start-stop-daemon --stop -o --name $NAME --exec $DAEMON
echo &quot;.&quot;
;;
restart|force-reload)
echo -n &quot;Restarting $DESC: $NAME&quot;
start-stop-daemon --stop -o --name $NAME --exec $DAEMON
sleep 1
start-stop-daemon --start -N $NICE -o --exec $DAEMON
echo &quot;.&quot;
;;
*)
echo &quot;Usage: /etc/init.d/$NAME {start|stop|restart|force-reload}&quot;
exit 1
;;
esac
exit 0
</pre>
<p>
You then have to add the backup service to your startup sequence:
</p>
<pre>
# update-rc.d networker defaults 90
</pre>
<p>
Now Legato should be setup up properly, and automatic backups run as configured
on the server.
</p>
<hr>
<h3><a name="s12.4.2"></a>12.4.2 Tar et al</h3>
<p>
Meta: Tar, dump, dd, cpio
</p>
<p>
Now for some examples.
</p>
<p>
In Debian GNU/Linux the <code>tar</code> program is GNU tar, which has several
extra features. Among them is support for compressing the tar file while it is
created. On the average, compression squeezes the file to about 50% of the
uncompressed size. Your mileage may vary: files that are already compressed,
like *.zip and *.gif files do not compress at all, and some file compress
especially well, C source code files can go to 25% of the uncompressed size.
</p>
<p>
Taking a compressed tar file from /export/home partition goes like this:
</p>
<pre>
cd /export
tar czf /tmp/home.tgz ./home
</pre>
<p>
The <code>tar</code> file <code>/tmp/home.tgz</code> can be copied to another
disk, or to another computer. If you do not have any backup device, but have
two computers with free disk space, take a compressed <code>tar</code> of the
most important files and copy the tar to the other computer.
</p>
<hr>
<h3><a name="s12.4.3"></a>12.4.3 Backup software</h3>
<p>
Meta: amanda, other backup software in Debian
</p>
<p>
I do not have time to study these now, contribution would be welcome.
</p>
<ul>
<li>
<p>
afbackup
</p>
</li>
</ul>
<ul>
<li>
<p>
amanda
</p>
</li>
</ul>
<ul>
<li>
<p>
dds2tar
</p>
</li>
</ul>
<ul>
<li>
<p>
floppybackup
</p>
</li>
</ul>
<ul>
<li>
<p>
ftape-module
</p>
</li>
</ul>
<ul>
<li>
<p>
jaztool
</p>
</li>
</ul>
<ul>
<li>
<p>
kbackup
</p>
</li>
</ul>
<ul>
<li>
<p>
mirrordir
</p>
</li>
</ul>
<ul>
<li>
<p>
tob
</p>
</li>
</ul>
<hr>
<h2><a name="s12.5"></a>12.5 Types of backup</h2>
<p>
Meta: Full, incremental, differential, network, dump, level 0--9,
</p>
<p>
There are different kinds of backups, the following lists some of them:
</p>
<dl>
<dt>Full</dt>
<dd>
<p>
Full backup means backing up everything.
</p>
</dd>
</dl>
<dl>
<dt>Incremental</dt>
<dd>
<p>
Incremental backup means backing up everything that has changed since last full
backup.
</p>
</dd>
</dl>
<dl>
<dt>Differential</dt>
<dd>
<p>
Differential seems to be another name for incremental.
</p>
</dd>
</dl>
<dl>
<dt>Network</dt>
<dd>
<p>
Network backup usually means backing up a client to a backup server, this means
the client sends the files to the server and the server writes them to backup
medium.
</p>
</dd>
</dl>
<dl>
<dt>Dump</dt>
<dd>
<p>
Dump backups are not ordinary file by file backups. The whole disk partition
or file system is &quot;dumped&quot; to the backup medium as is. This means it
is also necessary to restore the whole partition or file system at one go. The
dump backup may be a disk image, which means it must be restored to a similar
disk with same disk geometry and bad blocks in same places. Watch out for
this.
</p>
</dd>
</dl>
<dl>
<dt>Level 0 -- 9</dt>
<dd>
<p>
Level 0 to 9 backups are a finer grained version of incremental backups. Level
<var>N</var> backup means backing up everything that has changed since a same
or lower lever backup.
</p>
</dd>
</dl>
<p>
Meta: Check the backup can be restored, with original file owners, permissions
and timestamps.
</p>
<p>
To be useful, you must be able to restore the backup. Very often not only the
contents of file are important, but their time stamps, permissions and owners.
Check that you can restore the backup so that all these are preserved.
</p>
<hr>
<p>
[ <a href="ch-sysadmin-accounting.html">previous</a> ]
[ <a href="index.html#contents">Contents</a> ]
[ <a href="ch-sysadmin-intro.html">1</a> ]
[ <a href="ch-sysadmin-overview.html">2</a> ]
[ <a href="ch-sysadmin-files.html">3</a> ]
[ <a href="ch4.html">4</a> ]
[ <a href="ch-sysadmin-directories.html">5</a> ]
[ <a href="ch-sysadmin-filesystems.html">6</a> ]
[ <a href="ch-sysadmin-booting.html">7</a> ]
[ <a href="ch-sysadmin-users.html">8</a> ]
[ <a href="ch-sysadmin-sessions.html">9</a> ]
[ <a href="ch-sysadmin-printing.html">10</a> ]
[ <a href="ch-sysadmin-accounting.html">11</a> ]
[ 12 ]
[ <a href="ch-sysadmin-X.html">13</a> ]
[ <a href="ch-sysadmin-security.html">14</a> ]
[ <a href="ch-sysadmin-config.html">15</a> ]
[ <a href="ch-sysadmin-time.html">16</a> ]
[ <a href="ch-sysadmin-localisation.html">17</a> ]
[ <a href="ch-sysadmin-index.html">18</a> ]
[ <a href="ch-sysadmin-X.html">next</a> ]
</p>
<hr>
<p>
Debian GNU/Linux System Administrator's Manual (Obsolete Documentation)
</p>
<address>
This manual is OBSOLETE and DEPRECATED since 2006, 29 Dezember 2009. Instead see http://www.de.debian.org/doc/user-manuals#quick-reference.<br>
<br>
Ardo van Rangelrooij <code><a href="mailto:ardo.van.rangelrooij@tip.nl">ardo.van.rangelrooij@tip.nl</a></code><br>
Tapio Lehtonen <code><a href="mailto:Tapio.Lehtonen@IKI.FI">Tapio.Lehtonen@IKI.FI</a></code><br>
Oliver Elphick - Previous maintainer<br>
<br>
</address>
<hr>
</body>
</html>