csbackup(1)
===========

NAME
----

csbackup - csbackup

SYNOPSIS
--------

*csbackup* [*-s* | *--setup*] [*-k* | *--keys* ] [*-e* | *--etc* ] [*-c* | *--crontab*] [*-l* | *--logfile* 'FILE'] [*-i* | *--inside-cs*] [*-m* | *--mailremainder* 'EMAIL']

DESCRIPTION
-----------

*csbackup* is a wrapper around rsync written in bash to sync files to a file
server with some nice extra goodies to make life easier.

*Features:*

	- When run from a cronjob, some nice visual feedback will be displayed to
	  the currently logged-in user via popup notifications.

	- Backup of a whole list of user specified directories. Note that by
	  default only the files under '$HOME/csbackup' are considered.

	- Easy command line option to setup a cronjob to automate the backup
	  process.

	- Automatically check if the machine is inside the CS network and only
	  perform a backup if this is the case.

	- *csbackup* offers a simple way of setting up email reminders to warn you
	  if you haven't performed a successful backup in some time.

	- Files in a directory with name `NoCsBack'are 'not' backuped.

	- There is a per-directory file exclusion mechanism via .NoCsBack files.

OPTIONS
-------
*-s*, *--setup*::
	Prepare the directory structure at server side
*-k*, *--keys*::
	Force creation of an ssh key pair and upload the public key to the file
	server. 
	*Note:* As this action requires shell access on the file server, you will
	be prompted for your password.
*-e*, *--etc*::
	Create backup of the files in /etc. Use this option _only_ when running
	the script manually as it will need the root password to be able to
	read the files in /etc.
*-c*, *--crontab*::
	Create a cron job to schedule regular synchronization. The job is run daily
	at a randomly chosen time between 11h-13h. This option can be combined with
	--logfile or --inside-cs.
*-l*, *--logfile* 'FILE'::
	This option has only effect when used in combination with --crontab. The
	output of the cronjob is appended to 'FILE'.
*-i*, *--inside-cs*::
	Only do the backup if we are inside the CS network. If not, do nothing.
*-m*, *--mailremainder* 'EMAIL'::
	Setup an email remainder on the file server. By default, a message will be
	send to 'EMAIL' if there hasn't been a successful backup in 7 days. This
	command creates a cronjob on the file server. 
	*Note:* As this action requires shell access on the file server, you will
	be prompted for your password.

FIRST USE
---------

Before first use, you should do some setup:

1. Run *csbackup* manually from the command line. This will create a default
   config file '$HOME/.csbackuprc'.
   
2. Edit '$HOME/.csbackuprc' so that it contains the correct information! *This
   is important!*
   
3. After you have edited '$HOME/.csbackuprc', run *csbackup* manually a second
   time, now using the command 'csbackup --setup'. This will do two things:
   
	- Create and setup the ssh keypair (with empty passphrase) that will be
	  used to access the file server when performing the backup. You will be
	  asked for your password to login to the file server.

	- Setup the required directory structure on the backup host.

MAKING IT A BIT MORE SECURE
---------------------------

For security reasons, you might want to disable shell login with the ssh key
pair (it has an empty passphrase!) and only allow rsync connections. To this
end, you can do the following ON THE FILE SERVER:

   1. Create a file $HOME/bin/validate-rsync.sh with contents:

		#!/bin/sh
		case "$SSH_ORIGINAL_COMMAND" in
		*\&*)
		echo "Rejected" 
		;;
		*\;*)
		echo "Rejected"
		;;
		rsync\ --server*)
		$SSH_ORIGINAL_COMMAND
		;;
		*)
		echo "Rejected"
		;;
		esac

	  Make this file executable:

		chmod +x $HOME/bin/validate-rsync.sh

   2. Edit the file $HOME/.ssh/authorized_keys, adding a prefix command="..."
	  to the line containing the public key used for the backup. The result
	  should be of the form:

        command="$HOME/bin/validate-rsync.sh",no-pty,no-port-forwarding,no-agent-forwarding,no-X11-forwarding ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA+v4aFa7CgxlQCjyl/P1iF4AGTN3UJaW+iPQsyGJdSap0nR4Wzz9m/U2fOUJxEIOqFlyFd2V/eDHwEjYscKu767ascNOkF2kiagsRDcywn0KuFe++8DPoNttkvfxsWuKnsKXfJMI9Wl6jH5/8yQD6uOBJXvQz+OSe6HeFT/QJGIcIf2uqLEJFr6tkVAHTkaMe+RcrHXAS0/Ej64IOZbLQwlyIQOyS1+XDUkW6V04muapwBSdzlrfyLPa39GeG4YoSFpWHi3DWJs1oxYArfgr61xJEZ/jIY3brhtmY1NcHB3gbreSklLcILlgkjYIMsLlz8CivxgTk1vM53iAsPttRtQ== yves@dirac


TYPICAL USE CASES
-----------------

- Initial setup before first use:
+
..............................................................
csbackup
vi $HOME/.csbackuprc
csbackup --setup
..............................................................

- To setup a daily cronjob that only runs when inside the CS domain and writes a
  log to a file, you should run:
+
..............................................................
csbackup --cronjob --logfile $HOME/.csbackup.log --inside-cs
..............................................................
+
You can always manually edit the created job via the command
+
.............
crontab -e
.............

- Setup an email reminder that checks every day at 00:00 if the last successful
  backup is older than 7 days:
+
..............................................................
csbackup --mailremainder yves.frederix@cs.kuleuven.be
..............................................................
+
To fine tune (e.g., to use a different grace period), edit the cron job on
the file server:
+
......................
ssh <fileserver>
crontab -e
......................

- Backup with inclusion of the files in /etc:
+
......................
csbackup --etc
......................

- Specific files in a directory can be excluded by adding a file with name
  `.NoCsBack'. E.g., to exclude the files (or directories) `test1', you would
  create a file `.NoCsBack' with contents:
+
.........
- test1
.........
+
This file follows the syntax for rsync filter rules (see also the rsync man page).

BUGS
----
Of course there are no bugs in *csbackup*, only features ;)

AUTHORS
-------
Yves Frederix <yves.frederix@cs.kuleuven.be>.

