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: Sam Mär 10 10:46:39 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
29 if [ -f "$CONFFILE" ] ; then
30 MASTERINFO="Notice: $CONFFILE exists already so I will not touch it.
31 Please do not forget to add $CLIENT to the file if you wan to use the 'Runall' functionality."
33 MASTERINFO="An initial master configuration ($CONFFILE) has been generated.
34 Please adjust it according to your needs."
35 cat > $CONFFILE << EOF
36 # Master configuration file for dirvish, created by $PN on $(date)
47 # var/cache/apt/archives
53 # .firefox/default/*/Cache/*
57 # add-another-client-here 22:00
59 # See http://www.dirvish.org/debian.howto.html for further details:
60 expire-default: +30 days
62 # MIN HR DOM MON DOW STRFTIME_FMT
67 # * * * * 2-7 +15 days
75 test -f ~/.keychain/`uname -n`-sh && source ~/.keychain/`uname -n`-sh
79 # prompt user for directory which should be used
80 BACKUP_DIR="$(dialog --stdout --inputbox 'Please choose the directory where backups should be placed' 0 0 /backups)"
82 if ! [ -d "$BACKUP_DIR" ] ; then
83 dialog --stdout --title "${PN}" --yesno "The directory $BACKUP_DIR does not yet exist. Do you want me to create it for you? " 0 0
86 echo "mkdir $BACKUP_DIR"
87 echo "chmod 700 $BACKUP_DIR"
89 echo "warning: $BACKUP_DIR does not exist, skipped creation as requested"
95 CLIENT="$(dialog --stdout --inputbox 'Please choose the name for your client instance, also known as vault' 0 0 client1)"
99 TREE="$(dialog --stdout --inputbox 'Please choose the directory you want to backup from your client (also known as tree)' 0 0 /home)"
102 create_client_conf() {
103 mkdir -p "${BACKUP_DIR}/${CLIENT}/dirvish"
104 if [ -f "${BACKUP_DIR}/${CLIENT}/dirvish/default.conf" ] ; then
105 ewarn "Warning: ${BACKUP_DIR}/${CLIENT}/dirvish/default.conf exists already, ignoring creation." ; eend 0
107 cat > "${BACKUP_DIR}/${CLIENT}/dirvish/default.conf" << EOF
108 # Configuration file of client-side for dirvish created by $PN on $(date)
113 image-default: %Y-%m-%d
115 var/cache/apt/archives/*
119 rsh: ssh -i $HOME/.ssh/id_rsa_dirvish_${CLIENT}
125 CLIENTNAME="$(dialog --stdout --inputbox 'Please choose user login and hostname for the client you want to backup. Syntax: user@host' 0 0 root@$(hostname))"
127 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
129 if [ $? -eq 0 ]; then
130 [ -d "$HOME/.ssh" ] || mkdir "$HOME/.ssh"
131 einfo "Creating $HOME/.ssh/id_rsa_dirvish_${CLIENT} using ssh-keygen:"
132 ssh-keygen -t rsa -f "$HOME/.ssh/id_rsa_dirvish_${CLIENT}" ; eend $?
133 einfo "Running ssh-copy-id to copy ssh key to $CLIENTNAME:"
134 ssh-copy-id -i "$HOME/.ssh/id_rsa_dirvish_${CLIENT}.pub" $CLIENTNAME ; eend $?
139 dialog --stdout --title "${PN}" --yesno "Do you want to backup $CLIENT via network? Answering with no will use localhost [$(hostname)] as client." 0 0
141 if [ $? -eq 0 ]; then
144 CLIENTNAME=$(hostname) # use localhost only
149 einfo "Running $PN was successful. Enjoy using dirvish!" ; eend 0
151 einfo "Please adjust ${BACKUP_DIR}/${CLIENT}/dirvish/default.conf according to your needs.
153 Then run the following command to create an initial backup:
155 dirvish --summary long --vault $CLIENT --init
157 Find the backup inside $BACKUP_DIR/$CLIENT/$(date +%Y-%m-%d)/tree/ then.
159 Documentation available at:
161 man dirvish-locate.1 dirvish.conf.5 dirvish.8 dirvish-runall.8 dirvish-expire.8
162 /usr/share/doc/dirvish/HOWTO.upstream /usr/share/doc/dirvish/FAQ.html
163 /usr/share/doc/dirvish/HOWTO.Debian.gz
165 http://www.dirvish.org/
166 http://wiki.dirvish.org/
168 Please report bugs regarding ${PN}: http://grml.org/bugs/
174 echo "Usage: $PN" 1>&2
179 # now run the funtions:
184 create_client_conf && \
188 ## END OF FILE #################################################################
189 # vim: ft=sh ai tw=80 expandtab