2 # Filename: dirvish-setup
3 # Purpose: create basic setup for dirvish(8)
4 # Authors: grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports: see http://grml.org/bugs/
6 # License: This file is licensed under the GPL v2.
7 # Latest change: Fre Feb 23 23:49:58 CET 2007 [mika]
8 ################################################################################
10 # http://apt-get.dk/howto/backup/
11 # http://edseek.com/~jasonb/articles/dirvish_backup/advanced.html
12 # http://www.dirvish.org/svn/contrib/admin/DailyEmailScript/dirvish-status.sh
13 ################################################################################
17 . /etc/grml/script-functions
18 . /etc/grml/lsb-functions
21 check4progs dirvish rsync ssh-keygen ssh-copy-id
24 CONFFILE=/etc/dirvish/master.conf
26 # make sure we don't lose any files
27 if [ -f "$CONFFILE" ] ; then
28 mv $CONFFILE $CONFFILE.$(date +%Y%m%d).$$
34 cat > $CONFFILE << EOF
35 # Configuration file for dirvish, created by $PN on $(date)
45 # var/cache/apt/archives
51 # .firefox/default/*/Cache/*
56 # See http://www.dirvish.org/debian.howto.html for further details:
57 expire-default: +30 days
59 # MIN HR DOM MON DOW STRFTIME_FMT
64 # * * * * 2-7 +15 days
71 test -f ~/.keychain/`uname -n`-sh && source ~/.keychain/`uname -n`-sh
75 # prompt user for directory which should be used
76 BACKUP_DIR="$(dialog --stdout --inputbox 'Please choose the directory where backups should be placed' 0 0 /backups)"
78 if ! [ -d "$BACKUP_DIR" ] ; then
79 dialog --stdout --title "${PN}" --yesno "The directory $BACKUP_DIR does not yet exist. Do you want me to create it for you? " 0 0
82 echo "mkdir $BACKUP_DIR"
83 echo "chmod 700 $BACKUP_DIR"
85 echo "warning: $BACKUP_DIR does not exist, skipped creation as requested"
91 CLIENT="$(dialog --stdout --inputbox 'Please choose the name for your client instance, also known as vault' 0 0 client1)"
94 create_client_conf() {
95 mkdir -p "${BACKUP_DIR}/${CLIENT}/dirvish"
96 if [ -f "${BACKUP_DIR}/${CLIENT}/dirvish/default.conf" ] ; then
97 ewarn "Warning: ${BACKUP_DIR}/${CLIENT}/dirvish/default.conf exists already, ignoring creation." ; eend 0
99 cat > "${BACKUP_DIR}/${CLIENT}/dirvish/default.conf" << EOF
100 # Configuration file of client-side for dirvish created by $PN on $(date)
105 image-default: %Y-%m-%d
107 var/cache/apt/archives/*
111 rsh: ssh -i $HOME/.ssh/id_rsa_dirvish_${CLIENT}
117 CLIENTNAME="$(dialog --stdout --inputbox 'Please choose user login and hostname for the client you want to backup. Syntax: user@host' 0 0 root@$(hostname))"
119 dialog --stdout --title "${PN}" --yesno "Do you want me to create ssh setup for client ${CLIENTNAME} using ssh-keygen and ssh-copy-id?" 0 0
121 if [ $? -eq 0 ]; then
122 [ -d "$HOME/.ssh" ] || mkdir "$HOME/.ssh"
123 einfo "Creating $HOME/.ssh/id_rsa_dirvish_${CLIENT} using ssh-keygen:"
124 ssh-keygen -t rsa -f "$HOME/.ssh/id_rsa_dirvish_${CLIENT}" ; eend $?
125 einfo "Running ssh-copy-id to copy ssh key to $CLIENTNAME:"
126 ssh-copy-id -i "$HOME/.ssh/id_rsa_dirvish_${CLIENT}.pub" $CLIENTNAME ; eend $?
131 dialog --stdout --title "${PN}" --yesno "Do you want to backup $CLIENT via network? Answering with no will use localhost [$(hostname)] as client." 0 0
133 if [ $? -eq 0 ]; then
136 CLIENTNAME=$(hostname) # use localhost only
141 einfo "Running $PN was successful. Enjoy using dirvish!" ; eend 0
143 einfo "Please adjust ${BACKUP_DIR}/${CLIENT}/dirvish/default.conf according to your needs.
144 Then run the following command to create an initial backup:
146 dirvish --summary long --vault $CLIENT --init
148 Find the backup inside $BACKUP_DIR/$CLIENT/$(date +%Y-%m-%d)/tree/ then.
150 Documentation available at:
152 man dirvish-locate.1 dirvish.conf.5 dirvish.8 dirvish-runall.8 dirvish-expire.8
153 /usr/share/doc/dirvish/HOWTO.upstream /usr/share/doc/dirvish/FAQ.html
154 /usr/share/doc/dirvish/HOWTO.Debian.gz
156 http://www.dirvish.org/
157 http://wiki.dirvish.org/
159 Please report bugs regarding ${PN}: http://grml.org/bugs/
165 echo "Usage: $PN" 1>&2
170 # now run the funtions:
174 create_client_conf && \
178 ## END OF FILE #################################################################
179 # vim: ft=sh ai tw=80 expandtab