aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2012-05-17 14:55:57 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2012-05-17 15:05:46 +0300
commit6b8fa542771cc9a93a9ecdfb20da9cea0781f1c4 (patch)
treee9998bd888fb29829e013a2de825a74b6e8db87d
downloadbeam-6b8fa542771cc9a93a9ecdfb20da9cea0781f1c4.tar.gz
beam-6b8fa542771cc9a93a9ecdfb20da9cea0781f1c4.tar.bz2
Initial import
-rw-r--r--.gitignore25
-rw-r--r--AUTHORS1
-rw-r--r--Make.rules6
-rw-r--r--Makefile.am34
-rw-r--r--NEWS0
-rw-r--r--THANKS0
-rw-r--r--backup.conf112
-rw-r--r--backup.in110
-rw-r--r--configure.ac15
-rw-r--r--doc/.gitignore3
-rw-r--r--doc/Makefile.am7
-rw-r--r--doc/backup.1in208
-rw-r--r--doc/backup.conf.5in237
-rw-r--r--doc/restore.1in134
-rw-r--r--examples/Makefile.am1
-rw-r--r--examples/backup.conf.s3136
-rw-r--r--lib/Makefile.am1
-rw-r--r--lib/backup/.gitignore1
-rw-r--r--lib/backup/Makefile.am11
-rw-r--r--lib/backup/common.in86
-rwxr-xr-xlib/backup/fs.sh92
-rwxr-xr-xlib/backup/postgres.sh72
-rw-r--r--restore.in167
23 files changed, 1459 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..95cde12
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,25 @@
+*~
+.deps
+.emacs*
+.libs
+ABOUT-NLS
+COPYING
+ChangeLog
+INSTALL
+Makefile
+Makefile.in
+TAGS
+aclocal.m4
+autom4te.cache
+build-aux
+config.h
+config.h.in
+config.log
+config.status
+configure
+core
+backup.sh
+restore.sh
+build.sed
+*.tar.*
+tmp
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..db7f07f
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1 @@
+Sergey Poznyakoff <gray@gnu.org.ua>
diff --git a/Make.rules b/Make.rules
new file mode 100644
index 0000000..013402b
--- /dev/null
+++ b/Make.rules
@@ -0,0 +1,6 @@
+.in.sh:
+ $(AM_V_GEN)sed -f $(top_builddir)/build.sed $< > $@
+.1in.1:
+ $(AM_V_GEN)sed -f $(top_builddir)/build.sed $< > $@
+.5in.5:
+ $(AM_V_GEN)sed -f $(top_builddir)/build.sed $< > $@
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..7702ede
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,34 @@
+SUBDIRS=. lib examples doc
+noinst_SCRIPTS=build.sed backup.sh restore.sh
+CLEANFILES=backup.sh restore.sh
+install-exec-hook:
+ for file in backup restore; \
+ do \
+ test -z "$(DESTDIR)$(bindir)" || \
+ $(mkdir_p) "$(DESTDIR)$(bindir)"; \
+ ${INSTALL} $(top_builddir)/$$file.sh \
+ $(DESTDIR)$(bindir)/$$file; \
+ done
+install-data-hook:
+ test -z "$(DESTDIR)$(sysconfdir)" || \
+ $(mkdir_p) "$(DESTDIR)$(sysconfdir)"; \
+ if test -f $(DESTDIR)$(sysconfdir)/backup.conf; then :; else \
+ ${INSTALL} -m 644 $(top_srcdir)/backup.conf $(DESTDIR)$(sysconfdir);\
+ fi
+uninstall-hook:
+ for file in backup restore; \
+ do \
+ rm -f "$(DESTDIR)$(bindir)/$$file"; \
+ done
+backup.sh restore.sh: build.sed
+EXTRA_DIST=backup.in restore.in backup.conf
+distuninstallcheck_listfiles=find $(DESTDIR)$(prefix) -type f -not -wholename '$(DESTDIR)$(sysconfdir)/backup.conf'
+
+$(top_builddir)/build.sed: Makefile
+ $(AM_V_GEN){ \
+ echo 's|@''SYSCONFDIR''@|${sysconfdir}|g';\
+ echo 's|@''LIBDIR''@|${libdir}|g'; \
+ echo 's|@''BINDIR''@|${bindir}|g'; \
+ } > $(top_builddir)/build.sed
+DISTCLEANFILES=build.sed backup.sh restore.sh
+include $(top_srcdir)/Make.rules
diff --git a/NEWS b/NEWS
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/NEWS
diff --git a/THANKS b/THANKS
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/THANKS
diff --git a/backup.conf b/backup.conf
new file mode 100644
index 0000000..297024f
--- /dev/null
+++ b/backup.conf
@@ -0,0 +1,112 @@
+# -*- shell-script -*-
+# This is a sample config file for the backup system. Tailor it to your
+# needs and remove the line below:
+echo >&2 "$0: WARNING: using default configuration boilerplate"
+
+# This file is essentially a shell script defining variables used by
+# the backup scripts. For a detailed information about it see backup.conf(5)
+# To debug the configuration, run "backup --dry-run" and "restore --dry-run".
+# For a detailed descriptions of these commands, see backup(1).
+
+# When set, the prologue hook is called right before starting backup or
+# restore. Similarly, the epilogue_hook is called immediately after
+# finishing all operations.
+# Use these hooks to perform any preliminary and/or cleanup jobs that
+# might be necessary in your setup.
+# When set, these variables must point to shell functions taking no
+# arguments. The best place to define such functions is perhaps in this
+# configuration file as well.
+#
+# By default, both variables are empty, i.e. no hooks are executed.
+
+prologue_hook=
+epilogue_hook=
+
+##########################################################################
+# Tar setup.
+#
+# Tar setup variables configure invocation of tar.
+#
+##########################################################################
+
+# Any additional options to pass to tar. Do not place tar operation
+# switches (as -c, -t, etc.) here! These will be added automatically
+# by appropriate scripts, depending on the operation being performed.
+#
+# By default this variable is empty (no additional options).
+#
+# In this example it is used to request bzip2 compression:
+backup_tar_options="-j"
+
+# Suffix for archive files.
+# Default is "tar"
+#
+backup_suffix="tar.bz2"
+
+# Directory where archive files are to be located. It's OK to specify
+# a remote directory here, e.g. 10.10.0.1:/export/backup
+#
+# This variable must be set. Whatever directory it points to must already
+# exist, the backup script won't create it.
+backup_archive_dir=/var/run
+
+# Directory where to store snapshot files. The files will be named as
+# their archive counterparts, with the suffix ".db".
+#
+# This variable must be set
+backup_snapshot_dir=/var/run
+
+# Set this variable to a non-empty value if you wish backup procedures to
+# be verbose.
+backup_verbose=
+
+##########################################################################
+# Backup items.
+#
+# Backup items are symbolic names that identify abstract objects that
+# need to be backed up (or restored). These must be valid shell variable
+# names. For each backup item <name>, this configuration file defines a
+# set of variables which determine what files to backup and what methods
+# to use for that. Each such variable is named <name>_<variable>, where
+# <name> is the item name, and <variable> is the variable name. The set
+# of variables needed depends on the type of each particular item.
+#
+##########################################################################
+
+# The following are sample entries. Be sure to edit them
+
+# Define the list of items to back up.
+# This variable must be set.
+backup_items="dbdump system"
+
+# For each item in $backup_items, at least its type (variable <item>_type)
+# must be declared. The item type determines the mechanism used to backup
+# and restore it. Valid item types are:
+#
+# fs back up a file system
+# postgres back up a postgres database
+#
+# You may define additional types, if you need. To do so, create an executable
+# file named <type>.sh in the directory @LIBDIR@/backup. See backup_type(5),
+# for a detailed description.
+#
+
+# Dump Postgres database "mydb".
+# The <item>_database is the only variable required by type "postgres".
+dbdump_type=postgres
+dbdump_database="mydb"
+
+# Back up directories in the file system.
+# The "fs" type requires at least to variables:
+#
+# <item>_dir specifies the directory (usually, but not necessarily a mount
+# point), under which the directories and files to be backed up are located.
+#
+# <item>_files specifies a list of directories and/or files in that directory.
+
+system_type=fs
+system_dir="/"
+system_files="etc var/spool"
+
+
+
diff --git a/backup.in b/backup.in
new file mode 100644
index 0000000..f14850f
--- /dev/null
+++ b/backup.in
@@ -0,0 +1,110 @@
+#! /bin/bash
+# This script creates a backup of this system. For usage instructions,
+# run `backup --help'. For a detailed description of the backup and
+# restore procedures, see /export/backup/snapshot/README.
+
+libdir=@LIBDIR@/backup
+set -e
+. $libdir/common.sh
+set +e
+ts=`date +%Y%m%d`;
+week=`date +%U`
+
+# Add version-specific tar options
+tar_version_options() {
+ set -- $(tar --version | awk 'NR==1 {gsub(/\./, " ",$NF); print $NF}')
+ if [ $# -ge 2 ]; then
+ v=$((1 * 1000 + $2))
+ if [ $v -gt 1025 ]; then
+ taroptions="$taroptions --level=$level"
+ fi
+ fi
+}
+
+load_config
+taroptions="-Hpax $backup_tar_options $backup_rsh_command"
+
+###########################################################
+# Global variables
+###########################################################
+
+# Set it to "-v" to make script verbose
+if [ -n "$backup_verbose" ]; then
+ verbose=-v
+else
+ verbose=
+fi
+# Set it to "echo" to initiate dry-run mode.
+dry_run=
+
+# Number of tar errors detected during the run
+tarerror=0
+
+level=0
+round=0
+
+###########################################################
+# Utility functions
+###########################################################
+
+help() {
+ cat <<EOF
+usage: $0 [OPTIONS]
+makes incremental backup of that system
+
+OPTIONS:
+
+ -v, --verbose increase verbosity
+ -l, --logfile FILE log to FILE (default $backup_logfile)
+ -n, --dry-run do nothing, print what would have been done
+ -N, --no-logfile log to stderr
+ -L, --level N create incremental dump level N
+ -R, --round N mark archives with incremental round N
+ --week N force using week number N instead of the current one
+ -h, --help produce this help list
+EOF
+ exit 0
+}
+
+###########################################################
+# Main
+###########################################################
+
+while [ $# -ne 0 ]
+do
+ case $1 in
+ -v|--verbose) verbose="$verbose -v";;
+ -l|--logfile) shift; backup_logfile=$1;;
+ -n|--dry-run) dry_run=echo;;
+ -N|--no-logfile) backup_logfile=;;
+ -h|--help) help;;
+ -L|--level) shift; level=$1;;
+ -R|--round) shift; round=$1;;
+ --week) shift; week=$1;;
+ *) echo >&2 "$0: unrecognized option $1"; exit 1;;
+ esac
+ shift
+done
+
+tar_version_options
+
+if [ -n "$backup_logfile" ]; then
+ exec >>$backup_logfile
+ exec 2>&1
+fi
+logit "started"
+
+$prologue_hook
+
+for item in $backup_items
+do
+ eval type=\$${item}_type
+ ${type}_backup $item
+done
+
+$epilogue_hook
+
+logit "finished"
+
+# finis coronat opus
+
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..b58cc91
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,15 @@
+AC_PREREQ(2.63)
+
+AC_INIT(backup, 1.0, gray@gnu.org.ua)
+AC_CONFIG_SRCDIR(backup.in)
+AC_CONFIG_AUX_DIR([build-aux])
+AM_INIT_AUTOMAKE([1.11 tar-ustar silent-rules])
+
+# Enable silent rules by default:
+AM_SILENT_RULES([yes])
+
+AC_OUTPUT(Makefile
+ lib/Makefile
+ lib/backup/Makefile
+ examples/Makefile
+ doc/Makefile)
diff --git a/doc/.gitignore b/doc/.gitignore
new file mode 100644
index 0000000..a3c168a
--- /dev/null
+++ b/doc/.gitignore
@@ -0,0 +1,3 @@
+backup.1
+restore.1
+backup.conf.5
diff --git a/doc/Makefile.am b/doc/Makefile.am
new file mode 100644
index 0000000..c7d6d3b
--- /dev/null
+++ b/doc/Makefile.am
@@ -0,0 +1,7 @@
+man_MANS = backup.conf.5 backup.1 restore.1
+backup.1: backup.1in Makefile
+backup.conf.5: backup.conf.5in Makefile
+restore.1: restore.1in Makefile
+EXTRA_DIST=backup.1in restore.1in backup.conf.5in
+DISTCLEANFILES=backup.conf.5 backup.1 restore.1
+include $(top_srcdir)/Make.rules
diff --git a/doc/backup.1in b/doc/backup.1in
new file mode 100644
index 0000000..b6087b5
--- /dev/null
+++ b/doc/backup.1in
@@ -0,0 +1,208 @@
+.\" This file is part of backup -*- nroff -*-
+.\" Copyright (C) 2012 Sergey Poznyakoff
+.\"
+.\" Backup is free software; you can redistribute it and/or modify
+.\" it under the terms of the GNU General Public License as published by
+.\" the Free Software Foundation; either version 3, or (at your option)
+.\" any later version.
+.\"
+.\" Backup is distributed in the hope that it will be useful,
+.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
+.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+.\" GNU General Public License for more details.
+.\"
+.\" You should have received a copy of the GNU General Public License
+.\" along with backup. If not, see <http://www.gnu.org/licenses/>.
+.\"
+.TH BACKUP 1 "May 17, 2012" "BACKUP" "Backup User Reference"
+.SH NAME
+backup \- create a back up.
+.SH SYNOPSIS
+.B backup
+[\fB\-h\fR] [\fB\-\-help\fR]
+
+.B backup
+[\fB\-vnN\fR] [\fB\-\-verbose\fR] [\fB\-l\fR \fIFILE\fR]\
+ [\fB\-\-logfile\fR \fIFILE\fR]\
+ [\fB\-\-dry\-run\fR]
+ [\fB\-L\fR \fIN\fR] [\fB\-\-level\fR \fIN\fR]
+ [\fB\-R\fR \fIN\fR] [\fB\-\-round\fR \fIN\fR] [\fB\-\-week\fR \fIN\fR]
+.SH DESCRIPTION
+The
+.B backup
+script creates full or incremental backups of file systems and other
+objects described in its configuration file
+.BR backup.conf .
+The configuration file by default is searched in
+.BR @SYSCONFDIR@ .
+Another location can be specified by setting the environment variable
+.B BACKUP_CONFIG
+to the full pathname of the configuration file.
+.PP
+After loading the configuration file, the script examines its command
+line for options that modify its behavior. These are described in
+detail in the section
+.BR OPTIONS ,
+below.
+.PP
+The script uses
+.BR tar (1)
+to produce incremental backups. The produced archives are named using
+the following pattern:
+.sp
+.nf
+.in +2
+.BR ITEM - WEEK - ROUND - LEVEL . SUFFIX
+.in
+.fi
+.sp
+where:
+.TP
+.B ITEM
+The name of the backup item. Backup items are defined in the
+configuration variable \fBbackup_items\fR and identify file systems
+(or other objects, such as PostgreSQL databases) to backup. See the
+section
+.B BACKUP ITEMS
+in
+.BR backup.conf (5),
+for a detailed description.
+.TP
+.B WEEK
+The number of week when this backup was taken. This is a number of
+week in year, formatted as a two-digit decimal number in the range 01
+to 53. Weeks are numbered starting with the first Sunday as the first
+day of week 01. For more details, see
+.BR strftime (3)
+conversion
+.BR %U .
+.TP
+.B ROUND
+The \fBround number\fR of this backup. This number identifies a
+particular series of incremental backups (starting at level 1), taken
+with respect to the same full backup.
+
+Consider for example the following backup schedule. A full backup is
+taken each Sunday. Then, during the week, incremental backups are
+taken daily: level one backup on Monday, level two backup on Tuesday,
+then again level one on Wednesday, and so on. In this scheme you get
+three rounds of backups each week. See the
+.B EXAMPLES
+section for an example of this schedule.
+.TP
+.B LEVEL
+Incremental level number.
+.TP
+.B SUFFIX
+The value of \fBbackup_suffix\fR configuration variable. If not set,
+.B tar
+is assumed.
+.PP
+The archives are stored in the directory specified by the
+.B backup_archive_dir
+configuration variable. This directory can be a local as well as a
+remote one. To use a remote location, set this variable to
+.sp
+.nf
+.in +2
+.BR HOST : DIR
+.in
+.fi
+.sp
+where
+.B HOST
+is the IP address or hostname of the remote machine, and
+.B DIR
+is the pathname on its file system. See the \fBThe GNU Tar Manual\fR,
+section 9.2 \fBRemote Tape Server\fR for more information on the subject.
+.PP
+The corresponding snapshots are stored in the directory specified by
+the \fBbackup_snapshot_dir\fR configuration variable and follow the
+same scheme as the archives, except that
+.B db
+is used as their suffix.
+.SH OPTIONS
+.TP
+\fB\-v\fR, \fB\-\-verbose\fR
+Increase verbosity. This overrides the \fBbackup_verbose\fR
+configuration variable.
+.TP
+\fB\-l\fR, \fB\-\-logfile\fR \fIFILE\fB
+Log to FILE. This overrides the \fBbackup_logfile\fR configuration
+variable.
+.TP
+\fB\-n\fR, \fB\-\-dry\-run
+Do nothing, print what would have been done. Use this to debug your
+configuration.
+.TP
+\fB\-N\fR, \fB\-\-no\-logfile
+Do not use \fBbackup_logfile\fR variable, log to standard error
+instead.
+.TP
+\fB\-L\fR, \fB\-\-level \fIN\fR
+Create incremental dump level \fIN\fR.
+.TP
+\fB-R\fR, \fB\-\-round \fIN\fR
+Mark archives with incremental round number \fIN\fR.
+.TP
+\fB\-\-week \fIN\fR
+Force using week number \fIN\fR. By default, the current week number
+(as returned by
+.BR strftime (3)
+conversion
+.BR %U )
+is used.
+.TP
+\fB\-h\fR, \fB\-\-help\fR
+Display a short help summary.
+.SH EXAMPLES
+Usually \fBbackup\fR is started as a cron job. The following
+example shows a root crontab designed so as to create full (level 0)
+backups on Sundays, level 1 backups on Mondays, Wednesdays and Fridays
+and level 2 backups on Tuesdays, Thursdays and Saturdays.
+.sp
+.nf
+.in +2
+# Create one full backup weekly.
+0 3 * * sun backup --round 0 --level 0
+# Create incremental backups daily.
+0 3 * * mon backup --round 0 --level 1
+0 3 * * tue backup --round 0 --level 2
+0 3 * * wed backup --round 1 --level 1
+0 3 * * thu backup --round 1 --level 2
+0 3 * * fri backup --round 2 --level 1
+0 3 * * sat backup --round 2 --level 2
+.in
+.fi
+.sp
+.SH FILES
+.TP
+.BR @SYSCONFDIR@/backup.conf
+Default configuration file.
+.TP
+.BR @LIBDIR@/backup
+Backup module directory. Whenever a backup item of type \fBT\fR is
+requested, \fBbackup\fR will attempt to load from this directory a
+file named \fBT.sh\fR. This file provides methods and definitions
+necessary to handle that particular item type.
+.TP
+.BR @LIBDIR@/backup/common.sh
+Settings and definitions shared between
+.BR backup
+and
+.BR restore (1).
+.SH "SEE ALSO"
+.BR restore (1),
+.BR backup.conf (5).
+.SH AUTHORS
+Sergey Poznyakoff
+.SH "BUG REPORTS"
+Report bugs to <gray@gnu.org.ua>.
+.\" Local variables:
+.\" eval: (add-hook 'write-file-hooks 'time-stamp)
+.\" time-stamp-start: ".TH [A-Z_][A-Z0-9_]* [0-9] \""
+.\" time-stamp-format: "%:B %:d, %:y"
+.\" time-stamp-end: "\""
+.\" time-stamp-line-limit: 20
+.\" end:
+
diff --git a/doc/backup.conf.5in b/doc/backup.conf.5in
new file mode 100644
index 0000000..aa0bfe8
--- /dev/null
+++ b/doc/backup.conf.5in
@@ -0,0 +1,237 @@
+.\" This file is part of backup -*- nroff -*-
+.\" Copyright (C) 2012 Sergey Poznyakoff
+.\"
+.\" Backup is free software; you can redistribute it and/or modify
+.\" it under the terms of the GNU General Public License as published by
+.\" the Free Software Foundation; either version 3, or (at your option)
+.\" any later version.
+.\"
+.\" Backup is distributed in the hope that it will be useful,
+.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
+.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+.\" GNU General Public License for more details.
+.\"
+.\" You should have received a copy of the GNU General Public License
+.\" along with backup. If not, see <http://www.gnu.org/licenses/>.
+.\"
+.TH BACKUP.CONF 1 "May 16, 2012" "BACKUP.CONF" "Backup User Reference"
+.SH NAME
+backup.conf \- configuration file for backup system
+.SH DESCRIPTION
+The \fBbackup.conf\fR configuration file defines what files are to be
+included in the backup, what backup methods to use and where to store
+the resulting archives. The
+.BR backup (1)
+and
+.BR restore (1)
+utilities expect to find it in the
+.B @SYSCONFDIR@
+directory.
+.SH SYNTAX
+The file is essentially a shell script that defines variables
+controlling backup and restore procedures. The names of the variables
+used by the backup scripts begin with
+.BR backup_ .
+.SH GENERAL SETUP
+.TP
+.B backup_logfile
+If set, redirect standard error and standard output to that file. The
+file will be created if it does not exist. Otherwise, the output will be
+appended to it.
+.TP
+.B backup_rsh_command
+Use this command to access remote archives. Unless set, the backup
+utilities will first look for an executable file named
+.BR @BINDIR@/speedssh .
+If not found, they will fall back to using \fB/usr/bin/ssh\fR. It is
+the responsibility of the administrator to provide for authentication
+on the remote system, e.g. by using shared-key authentication.
+.SH TAR SETUP
+Tar setup variables control additional options and arguments passed to
+.BR tar (1).
+.TP
+.B backup_tar_options
+Use this variable to pass additional options to tar. Do not place tar
+operation switches (such as \fB-c\fR, \fB-t\fR, etc.) here! These
+will be added automatically by appropriate scripts, depending on the
+operation being performed
+
+By default this variable is empty (no additional options passed to tar).
+.TP
+.B backup_suffix
+This variable supplies suffix for created archive names. The default
+is
+.B tar .
+The dot is inserted between the file name and its suffix.
+
+This variable is useful if you request compression and want archive
+file names to reflect it. For example:
+.sp
+.nf
+.in +2
+backup_tar_options="-j"
+backup_suffix="tar.bz2"
+.in
+.fi
+.sp
+.TP
+.B backup_archive_dir
+Directory where archive files are located. It's OK to specify
+a remote directory here, e.g.
+.sp
+.nf
+.in +2
+backup_archive_dir="10.10.0.1:/export/backup"
+.in
+.fi
+.sp
+This variable must be defined and whatever directory it points to must
+already exist.
+.TP
+.B backup_snapshot_dir
+Directory for incremental snapshot files. These files are be named after
+their archive counterparts, by appending the
+.B .db
+suffix.
+.TP
+.B backup_verbose
+Set this variable to any non-empty value to request additional
+verbosity. The effect of this setting depends on backup methods being
+used. For example, the
+.B fs
+method adds a
+.B \-v
+option to each invocation of
+.BR tar (1).
+.SH BACKUP ITEMS
+A
+.B backup item
+identifies information that needs to be backed up. Syntactically,
+items follow the same rules as shell variable names. Backup items
+are introduced using the following variable:
+.TP
+.B backup_items
+A whitespace-separated list of backup items.
+.PP
+For each backup item
+.B name
+the configuration file must provide a set of variables describing
+where to obtain this information and how to store it to the archive.
+These variables follow the same naming convention:
+.sp
+.nf
+.in +2
+\fBname\fR_\fBvar\fR
+.in
+.fi
+.sp
+where \fBname\fR is the item name and \fIvar\fR is a valid shell
+identifier.
+
+The
+.B \fBname\fR_type
+variable must always be defined. It identifies the backup method
+to be applied to that item. Currently two backup methods are
+implemented:
+.TP
+.B fs
+A file system backup.
+.TP
+.B postgres
+Backup of a PostgreSQL database.
+.SH FS BACKUP TYPE
+This is the basic backup type, which means incremental backups of a
+specified file system. For each item of this type, the following
+variables must be defined:
+.TP
+.B \fIitem\fB_dir
+The absolute path to the file system being backed up.
+.TP
+.B \fIitem\fB_files
+A whitespace-separated list of directories and/or files in the
+.B \fIitem\fB_dir
+directory.
+.PP
+For example:
+.sp
+.nf
+.in +2
+backup_items="system"
+
+system_type=fs
+system_dir="/"
+system_files="etc var/spool"
+.in
+.fi
+.sp
+This configuration requests incremental backups of everything found in
+the directories \fB/etc\fR and \fB/var/spool\fR.
+.SH POSTGRES BACKUP TYPE
+The
+.B postgres
+type creates a dump of a PostgreSQL database and archives it using
+.BR tar (1).
+The following variables must be defined for items of this type:
+.TP
+.B \fIitem\fB_database
+The database name.
+.SH HOOKS
+Two special variables, called hooks, allow you to supply arbitrary
+procedures to be run before and after backup.
+.TP
+.B prologue_hook
+This variable contains the name of a shell procedure or external
+program to be called before starting backup (or restore). The hook is
+called without arguments. By default, this variable is empty.
+.TP
+.B epilogue_hook
+This variable contains the name of a shell procedure or external
+program to be called after backup (or restore) is finished. The hook
+is called without arguments. By default, this variable is empty.
+.SH EXAMPLES
+A simple configuration file for backing up the contents of
+.BR /etc,
+.BR /home ,
+and the PostreSQL database
+.BR savane :
+.sp
+.nf
+.in +2
+# Request bzip2 compression:
+backup_tar_options="-j"
+# Modify file name suffix accordingly
+backup_suffix="tar.bz2"
+# Write data to \fB/dev/rmt1\fR on a remote machine:
+backup_archive_dir=192.168.0.1:/dev/rmt1
+# Keep snapshots in this directory:
+backup_snapshot_dir=/var/snapshots
+
+# Two backup items are defined:
+backup_items="dbdump system"
+
+# The \fBdbdump\fR item dumps the database:
+dbdump_type=postgres
+dbdump_database=savane
+
+# The \fBsystem\fR item backs up the file system:
+system_type=fs
+system_dir="/"
+system_files="etc home"
+.in
+.fi
+.sp
+.SH "SEE ALSO"
+.BR restore (1),
+.BR backup (1).
+.SH AUTHORS
+Sergey Poznyakoff
+.SH "BUG REPORTS"
+Report bugs to <gray@gnu.org.ua>.
+.\" Local variables:
+.\" eval: (add-hook 'write-file-hooks 'time-stamp)
+.\" time-stamp-start: ".TH [A-Z_][A-Z0-9_]* [0-9] \""
+.\" time-stamp-format: "%:B %:d, %:y"
+.\" time-stamp-end: "\""
+.\" time-stamp-line-limit: 20
+.\" end:
+
diff --git a/doc/restore.1in b/doc/restore.1in
new file mode 100644
index 0000000..ee88781
--- /dev/null
+++ b/doc/restore.1in
@@ -0,0 +1,134 @@
+.\" This file is part of backup -*- nroff -*-
+.\" Copyright (C) 2012 Sergey Poznyakoff
+.\"
+.\" Backup is free software; you can redistribute it and/or modify
+.\" it under the terms of the GNU General Public License as published by
+.\" the Free Software Foundation; either version 3, or (at your option)
+.\" any later version.
+.\"
+.\" Backup is distributed in the hope that it will be useful,
+.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
+.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+.\" GNU General Public License for more details.
+.\"
+.\" You should have received a copy of the GNU General Public License
+.\" along with backup. If not, see <http://www.gnu.org/licenses/>.
+.\"
+.TH RESTORE 1 "May 17, 2012" "RESTORE" "Backup User Reference"
+.SH NAME
+restore \- restore file system from a backup.
+.SH SYNOPSIS
+.B restore
+[\fB\-h\fR] [\fB\-\-help\fR]
+
+.B restore
+[\fB\-cntv\fR] [\fB\-\-confirm\fR] [\fB\-C\fR \fIDIR\fR]\
+ [\fB\-\-directory\fR \fIDIR\fR] [\fB\-\-verbose\fR]
+ [\fB\-\-dry\-run\fR] [\fB\-\-list\fR] [\fB\-\-logfile\fR \fIFILE\fR]\
+ [\fB\-L\fR \fIN\fR] [\fB\-\-level\fR \fIN\fR]
+ [\fB\-R\fR \fIN\fR] [\fB\-\-round\fR \fIN\fR] [\fB\-\-week\fR \fIN\fR]
+ [\fBITEM\fR [\fBITEM\fR...]]
+.SH DESCRIPTION
+The
+.B restore
+utility restores the file system from incremental backups created
+using
+.BR backup (1).
+.PP
+The program reads its configuration from the file
+.B backup.conf
+located in the
+.B @SYSCONFDIR@
+directory, or from the file named in the environment variable
+.BR BACKUP_CONFIG .
+The configuration file must exist.
+.PP
+After loading the configuration file, the program examines its command
+line for options that modify its behavior. These are described in
+detail in the section
+.BR OPTIONS ,
+below.
+.PP
+Once the configuration loaded, the
+.B restore
+utility determines which backup archives to use for restoring. Unless
+being requested otherwise by the command line options, the utility
+selects the most recent set of backup files.
+.PP
+Before starting the restore, the utility displays the backup files it
+has selected and asks the user if he wishes to proceed. Empty line
+(the \fBCR\fR alone) or any word beginning with \fBY\fR
+(case-insensitive) is taken as affirmative. Otherwise, a negative
+answer is assumed and program terminates.
+.PP
+The program restores file systems and other backup items in the
+order they are listed in the \fBbackup_items\fR configuration
+variable. The \fBITEM\fR arguments override this default. If they
+are present, the program will restore only those items that are listed
+in the command line and exactly in the order they appear.
+.SH OPTIONS
+.TP
+\fB\-c\fR, \fB\-\-confirm\fR
+Do not ask for confirmation; run straight into restoring.
+.TP
+\fB\-C\fR, \fB\-\-directory\fR \fIDIR\fR
+Restore into directory \fIDIR\fR instead of \fB/\fR.
+.TP
+\fB\-v\fR, \fB\-\-verbose\fR
+Increase verbosity.
+.TP
+\fB\-n\fR, \fB\-\-dry\-run\fR
+Do nothing, but print what would have been done.
+.TP
+\fB\-t\fR, \fB\-\-list\fR
+List archive files, instead of extracting from them.
+.TP
+\fB\-l\fR, \fB\-\-logfile\fR \fIFILE\fB
+Log to \fIFILE\fR instead of the standard error. This option implies
+\fB\-\-confirm\R. Note also, that due to its specific nature
+.B restore
+ignores the \fBbackup_logfile\fR configuration setting.
+.TP
+\fB\-L\fR, \fB\-\-level\fR \fIN\fN
+Set incremental dump level to stop at.
+.TP
+\fB\-R\fR, \fB\-\-round\fR \fIN\fR
+Use archives from incremental round \fIN\fR.
+.TP
+\fB\-W\fR, \fB\-\-week\fR \fIN\fR
+Use archives from week \fIN\fR.
+.TP
+\fB\-h\fR, \fB\-\-help\fR
+Display a short help summary.
+.SH EXAMPLES
+.SH FILES
+.TP
+.BR @SYSCONFDIR@/backup.conf
+Default configuration file.
+.TP
+.BR @LIBDIR@/backup
+Backup module directory. Whenever a backup item of type \fBT\fR is
+requested, \fBrestore\fR will attempt to load from this directory a
+file named \fBT.sh\fR. This file provides methods and definitions
+necessary to handle that particular item type.
+.TP
+.BR @LIBDIR@/backup/common.sh
+Settings and definitions shared between
+.BR backup (1)
+and
+.BR restore.
+.SH "SEE ALSO"
+.BR backup (1),
+.BR backup.conf (5)
+.SH AUTHORS
+Sergey Poznyakoff
+.SH "BUG REPORTS"
+Report bugs to <gray@gnu.org.ua>.
+.\" Local variables:
+.\" eval: (add-hook 'write-file-hooks 'time-stamp)